1、关闭mysql服务
net stop mysql57
2、输入指令
mysqld --defaults-file="C:\Program Files\MySQL\MySQL Server
5.1\my.ini" --console --skip-grant-tables
3、打开第二个cmd窗口,上面那个不要关闭
mysql -u root -p
不打密码,直接回车进去
4、更改密码
UPDATE user SET authentication_string = PASSWORD('newpassword') where USER='root';
5、刷新退出
FLUSH PRIVILEGES;
quit
6、启动mysql,登录
net start mysql57
mysql -uroot -p