关闭服务net stop MySQL
用安全模式打开,mysqld --skip-grant-tables
这个时候,光标会一直闪。注意,不要动,打开另一个命令行窗口。
4.和前面一样的操作来到bin目录下,
登录 mysql -u root -p
密码为空,直接回车;
就可以进去了
然后
use mysql;
(可能先前的版本密码的抬头是password,5.7.11是 authentication_string,可以select * from user,查看一下)
(老版本)update user set password=password("123456") where user="root";
(5.7.11)update user set authentication_string=password("123456") where user="root";
最后,flush privileges;就OK了。
5.最后登录一下试试。
刚开始启动失败,是英文mysqld进程还开着呢,kill掉就行了。
最后,成功修改了root密码。