重置MySQL密码

停止MySQL服务

service mysqld stop

启动mysqld_safe ,跳过启动授权表。

启动时加上skip-grant-tables参数目的是在启动MySQL时不启动grant-tables,授权表。这样就可以修改root的密码了。

 mysqld_safe --skip-grant-tables &

登录MySQL,重置密码

mysql -uroot -p  //直接回车,不输入密码
use mysql;
update user set authentication_string=PASSWORD('12345678') where user="root";  
//注意老版本的mysql是password字段
 flush privileges;
 quit;

你可能感兴趣的:(重置MySQL密码)