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

浙公网安备 33010602011771号