tnblog
首页
视频
资源
登录
有个性,不需要签名
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术

本地MySql重置密码

6717人阅读 2019/6/12 9:54 总访问:265199 评论:0 收藏:0 手机
分类: sql
原理:通过跳过表授权,跳过密码直接在表里更新密码

  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

完了重启数据库服务



欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739

评价