【问题标题】:root password not working after changing my.ini更改 my.ini 后 root 密码不起作用
【发布时间】:2014-07-28 16:51:36
【问题描述】:

我忘记了我的根密码.... 然后我停止了 mysql 服务器并使用 skip-grant-tables 重新启动它; 我更改了root密码

mysql>update mysql.user set password='12345' where user='root';
mysql> select user,password from mysql.user;

我得到了这个::::

+------+-------------------------------------------+
| user | password                                  |
+------+-------------------------------------------+
| root | 12345                                     |
| waza | *8041F6A85F9698257ABF11AB449CC48FE6093750 |
| pma  |                                           |
| puru | *4538301D3121D4617B1EDE9CFAFDFEB70AFF9E08 |
+------+-------------------------------------------+

现在我停止了 mysql 服务器并更改了 my.ini 并删除了 skip-grant-tables; 重新启动mysql服务器::: 尝试使用密码 12345 在命令行上登录 而且它没有登录

C:\Users\hp-pc>mysql -u root -p
Enter password: *****
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

我该怎么办????

【问题讨论】:

  • 我通常建议不要直接对 mysql.user 表运行 UPDATE。你最好的选择是使用SET PASSWORD FOR 'root'@'localhost' = PASSWORD('cleartext password');
  • thanx 它可以工作.....但是如果我希望看到 *8041F6A85F9698257ABF11AB449CC48FE6093750 之类的密码该怎么办

标签: mysql


【解决方案1】:

您需要停止 mysqld 并使用 --skip-grant-tables 选项重新启动它。 这使任何人都可以在没有密码和所有权限的情况下进行连接。由于这是不安全的,您可能希望将 --skip-grant-tables 与 --skip-networking 结合使用以防止远程客户端连接。

确保您在更改密码后刷新特权

MySQL Documentation on Resetting Root Password

【讨论】:

  • 使用 --skip-grant-tables 我不能授予用户权限.....mysql> grant all privileges on *.* to 'root'@'%' identified by 'root_password';ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this sta tementmysql>
  • 当服务器重新加载授权表时,每个现有客户端连接的权限会受到如下影响: 表和列权限更改在客户端的下一个请求时生效。下次客户端执行 USE db_name 语句时,数据库权限更改将生效。注意 客户端应用程序可能会缓存数据库名称;因此,如果不实际更改为不同的数据库或刷新权限,他们可能看不到这种效果。
猜你喜欢
  • 2020-04-12
  • 2019-04-23
  • 2020-07-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-16
相关资源
最近更新 更多