mysql5.7在mysql root不知道密码的情况下密码重置

mysql5.7在mysql root不知道密码的情况下密码重置

1 停止mysql
systemctl stop mysqld
2 跳过密码登录
mysqld --user=mysql --skip-grant-tables --skip-networking &
mysql -u root
3 进入数据库后重置密码
flush privileges;
update mysql.user set authentication_string=password('new password') where user = 'root';
flush privileges;
exit;
4 重启mysql
pkill mysqld //停止mysql无授权进程
systemctl start mysqld//重启
5 登录MySQL
mysql -u root -p'new password'

posted @ 2025-04-17 17:26  95158  阅读(25)  评论(0)    收藏  举报