美文网首页
MySQL 5.7 重置密码

MySQL 5.7 重置密码

作者: 万有引力万有 | 来源:发表于2020-05-19 14:08 被阅读0次
  1. 修改 mysqld.cnf
/etc/mysql/mysql.conf.d/mysqld.cnf

增加一行

[mysqld]
....
skip-grant-tables
...
  1. 重启 mysql
sudo /etc/init.d/mysql restart
  1. 直接登录mysql
mysql
  1. 修改密码
update mysql.user set authentication_string=password('password') where host='localhost' and user='root';
flush privileges;
  1. 注释掉第一步添加的内容
[mysqld]
....
# skip-grant-tables
...
  1. 重启 mysql
sudo /etc/init.d/mysql restart
  1. 即可使用新的密码登录了

相关文章

网友评论

      本文标题:MySQL 5.7 重置密码

      本文链接:https://www.haomeiwen.com/subject/ughbohtx.html