一:dos窗口登录一定要通过管理员登录,不然后期后出错
![](https://img.haomeiwen.com/i15634691/fb910addac436464.png)
二:登录之后,键入以下指令
指令2--开启不安全模式,可直接越过输入密码直接进入数据库;指令:mysqld -nt -skip -grant -tables
![](https://img.haomeiwen.com/i15634691/e8cf6e1cb05883c8.png)
三:进入数据库(直接执行:mysql),更新密码,执行sql语句:update mysql.user set authentication_string=PASSWORD('新密码') where User='root' and host='localhost';
刷新权限,使用命令:flush privileges;
![](https://img.haomeiwen.com/i15634691/c93e09d3779b5db7.png)
四:杀死mysqld进程,方法:进入任务管理器结束进程mysqld.exe
![](https://img.haomeiwen.com/i15634691/dbd3351160d22659.png)
五:再次启动mysql服务,用命令net start mysql(win8以上系统需要管理员用户才能启动该服务)
![](https://img.haomeiwen.com/i15634691/7430e0a99c48840a.png)
网友评论