zoukankan      html  css  js  c++  java
  • 【MySQL解惑笔记】忘记MySQL数据库密码

    破解MySQL密码

    一、MySQL5.7.5之前

    只要有系统root密码就可以破解:
    [root@host-131 ~]# vim /etc/my.cnf               //在配置文件中加入如下内容
    [mysqld]
    skip-grant-tables
    
    [root@host-131 ~]# systemctl restart mysqld           //重启MySQL服务
    [root@host-131 ~]# mysql
    mysql> update mysql.user set password=password("Yanglt456.") where user="root" and host="localhost";    //设置密码
    mysql> flush privileges;                     //刷新                          
    mysql> q
    
    [root@host-131 ~]# vim /etc/my.cnf                          //注释掉下边内容,或者直接删除
    [mysqld]
    #skip-grant-table
    [root@host-131 ~]#systemctl restart mysqld           //重启服务

    一、MySQL5.7.6之后

    [root@host-131 ~]# vim /etc/my.cnf
    [mysqld]
    skip-grant-tables
    mysql> select user,host,authentication_string from mysql.user;
    +---------------+-----------+-------------------------------------------+
    | user          | host      | authentication_string                     |
    +---------------+-----------+-------------------------------------------+
    | root          | localhost | *8F59EEA84BC6AA6A57ECD4C0377518281DADC1BA |
    | mysql.session | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
    | mysql.sys     | localhost | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
    +---------------+-----------+-------------------------------------------+
    3 rows in set (0.01 sec)
    
    mysql> desc mysql.user;
    +------------------------+-----------------------------------+------+-----+-----------------------+-------+
    | Field                  | Type                              | Null | Key | Default               | Extra |
    +------------------------+-----------------------------------+------+-----+-----------------------+-------+
    | Host                   | char(60)                          | NO   | PRI |                       |       |
    | User                   | char(32)                          | NO   | PRI |                       |       |
    | authentication_string  | text                              | YES  |     | NULL                  |       |
    | password_expired       | enum('N','Y')                     | NO   |     | N                     |       |
    | password_last_changed  | timestamp                         | YES  |     | NULL                  |       |
    | password_lifetime      | smallint(5) unsigned              | YES  |     | NULL                  |       |
    | account_locked         | enum('N','Y')                     | NO   |     | N                     |       |
    +------------------------+-----------------------------------+------+-----+-----------------------+-------+
    45 rows in set (0.01 sec)
    
    mysql> update mysql.user set authentication_string=password("Yanglt456.") where user="root";
    mysql> flush privileges;
    mysql> q
    
    [root@host-131 ~]# vim /etc/my.cnf
    [mysqld]
    #skip-grant-tables  //注释掉
    [root@host-131 ~]# systemctl restart mysqld            //重启mysql服务
    [root@host-131 ~]# mysql -p"Yanglt456."                //密码已改变
  • 相关阅读:
    jquery 实现 html5 placeholder 兼容password密码框
    php返回json的结果
    使用PHP读取远程文件
    Sharepoint 自定义字段
    Sharepoint 中新增 aspx页面,并在页面中新增web part
    【转】Sharepoint 2010 配置我的站点及BLOG
    JS 实现 Div 向上浮动
    UserProfile同步配置
    【转】Import User Profile Photos from Active Directory into SharePoint 2010
    Sharepoint 2010 SP1升级后 FIMSynchronizationService 服务无法开启
  • 原文地址:https://www.cnblogs.com/yangleitao/p/9109607.html
Copyright © 2011-2022 走看看