mysql忘记密码的解决办法

1、写入配置文件

[root@wxj ~]# echo "skip-grant-tables" >>/etc/my.cnf

2、无密码登陆数据库修改密码

[root@wxj ~]# mysql -u root -p

3、修改密码(mysql5.7的密码表为authentication_strin

mysql> use mysql;
mysql> update user set authentication_string=password('Aa123456') where user='root';

4、去掉my.cnf配置文件的skip-grant-tables,重启服务

[root@wxj ~]# /etc/init.d/mysql.server restart

使用新密码登陆mysql,成功登陆

发表评论

后才能评论