mysql 忘记root密码修改方法

先将mysql安装bin目录(例如:c:xxxxxxmysqlin  加入环境变量)

1、在命令行窗口下输入net stop mysql5 或 net stop mysql

2、开一个命令行窗口,然后输入
mysqld -nt --skip-grant-tables;

3、再开一个DOS窗口,mysql -u root

4、输入:

 代码如下:

use mysql
update user set password=password("new_pass") where user="root";
flush privileges;
exit


5、使用任务管理器,找到mysqld-nt的进程,结束进程

然后再在命令行窗口输入:mysql -u root -p  回车

输入刚才设置的密码,发现已经可以进去了。

原文地址:https://www.cnblogs.com/demingblog/p/3947819.html