1.以管理员身份打开命令行窗口
2.在命令行中进入到MySQL的bin目录所在的文件夹中
net stop mysql80 //停止服务
cd [路径]
//E:\MySQL\MySQL Server 8.0\bin
3.跳过MySQL用户验证登录数据库
mysqld --console --skip-grant-tables --shared-memory
4.在新开的命令行中登录MySQL
//同样是切换到MySQL的bin目录下
mysql
5.修改密码,在命令行中输入
update user set authentication_string='*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' where user='root';
//*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 就是123456转化的值
来源:
https://blog.csdn.net/qq_45104014/article/details/127886570
https://blog.csdn.net/qq_43654669/article/details/126308931
https://blog.csdn.net/qq1090504117/article/details/122769709