mysql忘记密码修改方法

1. 修改/etc/my.cnf, 在mysqld中增加一行skip-grant-tables,记得改完密码,将这行再删除。

   保存,重启mysql

2. 使用一下命令直接进入,修改root密码

mysql  -uroot
use mysql;
update user set password = password ('需要设置的密码') where user = 'root';   #5.6版本

### update mysql.user set authentication_string=password('*******') where user='root'; ###5.7版本
flush privileges;

3. 重启mysql

将/etc/my.cnf 文件中修改的部分还原,然后重启mysql

service mysqld   restart 

猜你喜欢

转载自www.cnblogs.com/30go/p/10110098.html