MySQL 忘记密码解决方法
- 修改
mysql配置文件my.conf,在[mysqld]中加上一句:skip-grant-tables
- 重启
mysql,sudo systemctl restart mysql
- 连接
mysql, mysql -u root;, 更新密码,
MySQL 5.7.6 以及最新版本:
update user set authentication_string=PASSWORD('newpass') where user='root';
MySQL 5.7.5 或更早之前的版本:
update user SET password = password ('new-password') WHERE user = 'root';
flush privileges;
quit;
- 恢复登录设置,
mysql配置文件my.conf,删除在[mysqld]中:skip-grant-tables
- 重启,
sudo systemctl restart mysql


您将是第一位评论人!