MySQL 5.7 忘记密码。

  1. 修改配置文件:

[root@MySQL-S mysql]# vim /etc/my.cnf

2.在 [mysqld] 这个模块添加以下内容。

skip-grant-tables

3.重启 MySQL。

[root@MySQL-S mysql]# ./support-files/mysql.server restart

4.用空密码进入,回车。

[root@MySQL-S mysql]# mysql

  1. 执行语句。

mysql> alter user 'root'@'localhost' identified by '123456';

6.刷新:

mysql> flush privileges;

或:
update mysql.user set authentication_string=password('123456') where user='root' and Host = 'localhost';

猜你喜欢

转载自blog.51cto.com/13550113/2326179
今日推荐