29.centos7下忘记mysql数据库root密码

1、vim /etc/my.cnf

最后追加:skip-grant-talbes

以上表示mysql数据库重启后,可以无密码登录

2、重启msyql服务

无密码进入mysql

flush privileges; (必须)

alter user 'root'@'localhost' identified by '新密码';

flush privileges;

exit

3、vim /etc/my.cnf

注释掉刚才加的最后一行

#skip-grant-tables

4、重启数据库,新密码生效。



猜你喜欢

转载自blog.csdn.net/kevinsingapore/article/details/80983945