本机Windows忘记mysql的root密码

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服务
 

 

posted @ 2022-07-22 09:18  关键步就几步  阅读(216)  评论(0编辑  收藏  举报