mysql忘记root密码怎么办

1.以管理员身份进入cmd,进到MySQL所在的bin目录下,在命令行中输入: net stop mysql

2.待mysql服务停止后,输入: mysqld --shared-memory --skip-grant-tables ,此时命令提示符窗口处于锁定状态,我们重新以管理员权限打开新的命令提示符窗口。

3.在新的命令提示符窗口输入: mysql -uroot -p 后回车,提示输入密码时直接按回车进入。

4.输入: use mysql;

5.输入: update user set authentication_string='' where user='root'; ,将authentication_string置空。

6.先执行:flush privileges;

7.输入: alter user 'root'@'localhost' identified by 'newpassword'; newpassword是要设的新密码。

猜你喜欢

转载自blog.csdn.net/qq_53357781/article/details/122790336