1) 在C:\ProgramData\MySQL\MySQL Server 5.7\my.ini(Mysql配置文件)中 [mysqld] 下加入skip-grant-tables (免密登入)
2)、用navicat连接本机mysql,不用输入密码,直接root登录
3)、 在左侧右击选命令行窗口,执行刷新密码策略,然后修改密码
flush privileges (刷新密码策略,必须先执行该命令,不然会报错:ERROR 1290 (HY000): The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement)
alter user ‘root’@’localhost’ identified by ‘123456’ ; (修改root密码)
4) 修改配置文件,把免密登陆策略删掉。重启mysql服务
Original: https://www.cnblogs.com/javabg/p/16504527.html
Author: 关键步就几步
Title: 本机Windows忘记mysql的root密码
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/8268/
转载文章受原作者版权保护。转载请注明原作者出处!