Windows下重置mysql密码

1.关闭mysql服务

C:\Windows\System32目录下使用管理员身份运行cmd.exe

net stop mysql      #关闭mysql服务

2.修改配置文件,强行进入mysql

在mysql目录中,找到my.ini文件,添加一行配置

skip-grant-tables       #该配置可跳过输入密码环节

打开mysql服务

net start mysql      #启动mysql服务

进入mysql数据库

mysql -uroot -p       #直接回车,不用输密码

3.修改密码

修改密码为123456

update mysql.user set authentication_string=password('123456') where user='root';

刷新权限(很重要)

FLUSH PRIVILEGES;

4.恢复配置文件,使用密码登录

退出mysql
关闭mysql服务
恢复配置文件
启动mysql服务
使用密码登录mysql

mysql -uroot -p123456

猜你喜欢

转载自blog.csdn.net/hero_hope/article/details/82868046