mysql8.0版本忘记root密码

1、先关掉系统服务

net stop mysql

2、进入mysql安装目录的bin文件中,以管理员的方式运行cmd,然后输入如下命令,实现无密码登陆

mysqld --console --skip-grant-tables --shared-memory

3、以空密码登入系统

mysql.exe -u root

4、重置密码

UPDATE mysql.user SET authentication_string='root' WHERE user='root' and host='localhost';

5、ok


若不行,重装

原文地址:https://www.cnblogs.com/twodoge/p/10034405.html