centos7 忘记mysql5.7密码

编辑mysql配置文件

[root@bogon ~]# vi /etc/my.cnf

在  [mysqld] 配置节下新增  skip-grant-tables 

保存并重启mysql

//重启
[root@bogon ~]# systemctl restart mysqld

 登录mysql

[root@bogon ~]# mysql

 修改root密码

mysql> update mysql.user set authentication_string=password('密码') where user='root';
mysql> flush privileges;
mysql> quit

编辑mysql配置文件,将之前添加的skip-grant-tables去掉

重启mysql 

 

 

 

posted @ 2020-06-28 14:16  懶得取名  阅读(190)  评论(0编辑  收藏  举报