雨雨雨雨辰

本地MySql重置密码

电脑版发表于:2019/6/12 9:54
原理:通过跳过表授权,跳过密码直接在表里更新密码

  1. 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-pipe


  2. 2. 重启mysql服务

  3. 管理员打开命令行,密码不用输入直接回车

    1
    2
    3
    4
    1.mysql -u root -p
    2.update mysql.user set authentication_string=password('654321') where user = 'root';
    3.flush privileges;
    4.exit

效果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
C:\Program Files\MySQL\MySQL Server 5.7\bin>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.20-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql> update mysql.user set authentication_string=password('654321') where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

完了重启数据库服务


关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢