CentOS系统找回MySQL数据库root登录密码

1.修改配置文件:

vi /etc/my.cnf 添加 skip-grant-tables 保存退出

PS:要在【MySQL】下面添加

重启mysql:

centos7.x

systemctl restart mysqld

centos6.x

service mysqld restart

免密登录:

mysql -u root

进入数据库:

use mysql

修改root密码:

update user set authentication_string = password('新密码'),password_last_changed=now() where user='root';

刷新权限:

mysql>flush privileges;

退出mysql数据库:

quit

再次修改配置文件:

vi /etc/my.cnf 删除 skip-grant-tables 保存退出

重启mysql服务即可!!!

猜你喜欢

转载自blog.csdn.net/ichen820/article/details/114873274