本地MySql重置密码
电脑版发表于:2019/6/12 9:54
原理:通过跳过表授权,跳过密码直接在表里更新密码
1. 找到my.ini一般在
C:\Program Files\MySQL\MySQL Server 5.7\bin
1
2
3
4
5
6
7...
[mysqld]
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe找到这个片段,改为
1
2
3
4
5
6
7...
[mysqld]
skip-grant-tables
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe2. 重启mysql服务
管理员打开命令行,密码不用输入直接回车
1
2
3
41.mysql -u root -p
2.update mysql.user set authentication_string=password('654321') where user = 'root';
3.flush privileges;
4.exit
效果:
1 | C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p |
完了重启数据库服务!