首先,mysql忘记密码之后,进入不了mysql控制台。此时需要进行重置密码操作。mysql有一个后门
1.关闭mysql服务
systemctl stop mysql
2.在my.cnf添加 跳过检查配置
vim /etc/mysql/my.cnf
#添加以下配置
[mysqld]
skip-grant-tables
skip-networking
#保存退出
3.空密码进入mysql控制台
mysql -u root -p
mysql> use mysql
mysql> update user set authentication_string=‘’ where user=‘root’;
mysql> alter user ‘root’@‘%’ identified with mysql_native_password by ‘123456’;
mysql> flush privileges;
4.将my.cnf添加的配置注释掉,重启mysql服务
vim /etc/mysql/my.cnf
systemctl restart mysql
下一篇:一个高字两只手成语