破解 MySQL5.7 資料庫的 root 登錄密碼

2021-01-20 Linux就該這麼學

本文檔詳細介紹破解 MySQL5.7 資料庫的 root 登錄密碼,文內含長段代碼可複製可往左滑,希望對大家有幫助!

[root@MySQL1 ~]# mysql -uroot -p1231234
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

在 /etc/my.cnf 配置文件中添加 skip-grant-tables 繞開 MySQL5.7 資料庫密碼驗證

[root@MySQL1 ~]# echo skip-grant-tables >> /etc/my.cnf
[root@MySQL1 ~]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!

直接使用 mysql 命令登錄 MySQL5.7 資料庫並修改 root 登錄密碼

[root@MySQL1 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19-log Source distribution

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> ALTER  USER   'root'@'localhost'   IDENTIFIED BY  'password';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> ALTER  USER   'root'@'localhost'   IDENTIFIED BY  'password';
Query OK, 0 rows affected (0.00 sec)

mysql> quit
Bye

注意:如果在執行該步驟的時候出現 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement 錯誤。則執行下 flush privileges; 命令,再執行該命令即可。

使用新密碼 password 登錄 MySQL5.7 資料庫

[root@MySQL1 ~]# mysql -uroot -ppassword
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.19-log Source distribution

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> exit
Bye

[root@MySQL1 ~]# mysql -uroot -ppasswordd
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

刪掉 /etc/my.cnf 裡的 skip-grant-tables

[root@MySQL1 ~]# sed -i -e '/skip-grant-tables/d' /etc/my.cnf

[root@MySQL1 ~]# /etc/init.d/mysqld restart

以上就是破解 MySQL5.7 資料庫的 root 登錄密碼的方法,希望能給大家帶來幫助。

如果喜歡這位作者的文章,點點在看支持一下

官方站點:www.linuxprobe.com

 Linux命令大全:www.linuxcool.com

Linux系統下載站:www.linuxdown.com

劉遄老師QQ:5604922

Linux技術交流群:193666693

新群,火熱加群中……

書籍在線學習(電腦閱讀效果佳

http://www.linuxprobe.com/chapter-00.html

    想要學習Linux系統的讀者可以點擊"閱讀原文"按鈕來了解書籍《Linux就該這麼學》,同時也非常適合專業的運維人員閱讀,成為輔助您工作的高價值工具書!


相關焦點

  • MySql5.7忘記root密碼怎麼辦?
    skip-grant-tables2、重啟Mysql服務service mysqld restart3、使用命令行方式登錄Mysql,不用輸入密碼,直接回車即可mysql -u root -p4、查看下 mysql 版本5、選擇資料庫,修改 root 密碼> use mysql;
  • MySQL資料庫的更改密碼(附原始碼)
    以 MySQL 5.7 版本為例簡單講下主要過程: 首先修改配置文件,在[mysqld]部分加上一句:skip-grant-tables ,加上此參數的目的是跳過權限驗證。然後重啟資料庫,資料庫再次啟動後,我們就可以不用密碼直接登錄資料庫修改密碼了。
  • MySQL5.7資料庫安裝與遠程連接
    MySQL下載o 登錄網站:https://dev.mysql.com/downloads/mysql/o 選擇合適版本與系統Select version:5.7.31Select operating system
  • 如何在ubuntu20.04安裝MySQL並修改資料庫密碼
    sudo apt-get install mysql-server4、再次執行一下安裝mysql客戶端的命令5、接著,使用命令安裝客戶端所依賴的包安裝客戶端依賴包6、使用mysql -u root -p命令連接mysql服務,結果總是提示連接失敗;後來,查找到一種辦法,使用命令查找到另一用戶帳號和密碼
  • mysql 5.7 root密碼重置(centos 7)
    mysql5.7版本之後,與mariadb不同,在安裝之後,在啟動之時,會進行自動隨機密碼的設定,所以在systemctl start mysqld之後,會出現mysql -uroot -p無法登陸的情況mysql root原始密碼查看
  • MySQL暴力破解密碼
    ,我們可以給MySQL的登錄用戶增加一個保護的功能:當某一個用戶輸入錯誤密碼的次數超過指定的值後,禁止這個用戶再次馬上發起連接請求,這個禁止的時間長短可以靈活配置,不讓其再次嘗試登錄,從而避免用戶的密碼被暴力的破解。
  • 安裝MariaDB 10.2資料庫和破解MariaDB 10.2密碼最簡單的方法
    安裝資料庫添加yum源[root@bogon yum.repos.d]# vim /etc/yum.repos.d/CentOS-Base.repo更新yum源和安裝MariaDB 10.2[root@bogon yum.repos.d]
  • MySQL資料庫被黑客刪除僅留warning表 資料庫安全敲警鐘
    近期出現多例MySQL資料庫被刪除的情況,此事項多為mysql服務或所在伺服器允許外網可以訪問,伺服器密碼過於簡單,網站程序連接的時候使用了mysql root帳號權限,導致網站程序被黑的時候mysqlroot帳號密碼洩露,導致被黑客破解後,將資料庫清空,僅留下一張warning表。
  • MySQL 資料庫的安裝和密碼的設定
    MySQL資料庫是工作中經常需要使用的,因此了解資料庫的安裝及其基本的使用是非常有必要的。目前MySQL數據的安裝主要有兩個版本一個是.msi和zip壓縮包兩種形式。前者可以界面要求按步驟進行安裝,本次是以壓縮包的形式進行講解,希望對大家有用。
  • MySQL忘記密碼怎麼辦 密碼重置詳細教程
    登錄MySQL,密碼輸入錯誤/* 密碼錯誤,報如下錯誤 */[root@TESTDB ~]# mysql -uroot -p   -P3306 Enter password: ERROR 1045 (28000):
  • [玩轉MySQL之零]MySQL5.7三種安裝 方式及詳解
    如果是自建,並且以後都想自己運維資料庫,建議使用5.7,5.7在性能和數據同步方面做了很大的改進,特別是並行複製和多源複製。三、RPM安裝MySQL5.7作業系統默認包含的MySQL源比較老舊,如果需要安裝MySQL5.7,則需要從MySQL網站(https://dev.mysql.com/downloads/mysql/)下載相應的repo。3.1.
  • ubuntu下修改mysql資料庫密碼
    1.在終端輸入sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf2.在文件內搜索skip-external-locking,在下面添加一行:skip-grant-tables3.重啟mysql
  • Docker 安裝 MySQL5.7
    2、啟動Mysql容器啟動容器,並設置mysql忽略大小寫docker run -p 3306:3306 --name mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7  --lower_case_table_names=1 啟動成功(截圖中改為3316是因為本地已安裝mysql,埠衝突,大家忽略即可)
  • mysql-5.7.31-winx64解壓版安裝超詳圖文教程
    1.下載: 地址: https://dev.mysql.com/downloads/mysql/5.7.html 沒有帳號登錄需要申請一個帳號才能繼續下載。添加以下內容配置內容:[mysql]# 設置mysql客戶端默認字符集default-character-set=utf8[mysqld]#設置3306埠port = 3306# 設置mysql的安裝目錄basedir=D:\mysql-5.7.31-winx64# 設置mysql資料庫的數據的存放目錄
  • linux安裝Mysql5.7和安裝navicat(資料庫遠程連接工具)介紹
    下文命令行後『這個可以去官網換,打開它的下載連結即可yum -y install mysql57-community-release-el7-10.noarch.rpmyum -y install mysql-community-server ****如果使用yum下載方式很慢,執行以下三條語句************ *yum clean all
  • window 10 mysql 多版本安裝5.6和5.7
    一直在用mysql5.6、客戶那邊要求是5.7,因此在本地安裝多個版本,以供使用學習1、下載5.7 壓縮版本,請不要下載msi版本。https://dev.mysql.com/downloads/mysql/5.7.html2、解壓
  • 資料庫安全之Mysql資料庫安全加固
    普通用戶啟動禁止以root帳號運行mysqld;檢測操作檢查進程屬主和運行參數是否包含--user=mysql類似語句:> GRANT ALL ON *.* TO &39;@&39;;如上這種這其實是完全放開了所以ip對root的訪問。
  • 資料庫及Mysql入門,附詳細安裝教程
    創始人Michael Widenius的女兒Maria的名字  4.SQL server    微軟公司開發的大型關係型資料庫系統, 只能在window系統下運行  5.Access資料庫    入門級小型桌面資料庫  6.其他:DB2等種類
  • Centos7.9安裝Mariadb資料庫
    systemctl start mariadb # 開啟服務[root@localhost ~]# systemctl enable mariadb # 設置為開機自啟動服務 2、首次安裝需要進行資料庫的配置,命令都和mysql的一樣 [root@localhost ~]# mysql_secure_installation
  • mysql 8.0.11 資料庫用戶密碼修改詭異的限制
    近期,協助一客戶重置mysql 8.0.11的root密碼,碰到了奇怪的問題。 作業系統版本:rhel 7.6 資料庫版本:mysql 8.0.11 根據mysql 8.0官方文檔說明,mysql的用戶密碼有限制,並且被硬編碼,沒有明確說明密碼長度是多少。