Linux Centos7 Mysql 忘记密码怎么找回密码

Linux Centos7 Mysql 忘记密码怎么找回密码

1,跳过数据库权限验证

mysqld --skip-grant-tables --user=mysql &   

2,

            systemctl restart mysqld

正常情况是起不来 的等个大概10秒ctrl + c终止

3,输入mysql 即可进入

4,修改新密码

UPDATE mysql.user SET authentication_string=password('new_password')
WHERE user='root' AND host='localhost';  

5,刷新授权表

    FLUSH PRIVILEGES;   刷新授权表

6,exit 退出数据库重新用新密码登录,即可登录成功
7,最好reboot重启一下,使mysql变为运行状态

注意:报错处理

问题1:ERROR You must reset your password using ALTER USER statement before executing this statement

解决方案:ALTER USER 'root'@'localhost' IDENTIFIED BY 'xinmima';