1.停止MySQL服务
2.编辑MySQL配置文件,在[mysqld]节点中添加以下内容
skip-grant-tables
3.启动MySQL服务
4.输mysql回车进入mysql
#mysql
5.切换至mysql数据库
>use msyql
6.执行更新命令:
mysql> UPDATE user SET Password = password ( 'new-password' ) WHERE User = 'root' ;
7.找回密码后将/etc/my.cnf添加的内容注释掉
#skip-grant-tables
8.重启MySQL服务
service mysqld restart
密码找回完成!
https://www.leftso.com/article/247.html