千家信息网

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

发表于:2025-02-03 作者:千家信息网编辑
千家信息网最后更新 2025年02月03日,1,跳过数据库权限验证mysqld --skip-grant-tables --user=mysql & 2, systemctl restart mysqld正常情况是起不
千家信息网最后更新 2025年02月03日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';

0