mysql破解密碼
阿新 • • 發佈:2018-12-13
破解密碼
先停止 mysqld 服務
# service mysqld stop
編輯 mysql 的配置檔案 找到 [mysqld] 欄位 新增以下兩行並儲存退出
skip-grant-tables
skip-networking
再次啟動 mysql 在命令列直接輸出 mysql 就可以無需密碼登入到 mysql 終端
# mysql
在 mysql 終端 通過直接修改授權表的欄位 來更改新的 root 密碼 還需要 flush 重新整理一下
> update mysql.user set authentication_string=password('
[email protected]') where user='root' and host='localhost';
> flush privileges;
退出終端再次編輯 /etc/my.cnf 刪除掉剛剛新增的兩個引數或#註釋掉(skip-grant-tables skip-networking)
# vim /etc/my.cnf
#skip-grant-tables
#skip-networking
重啟 mysqld服務
# service mysqld start
登入資料庫時 使用新密碼 [email protected]
# mysql -uroot
[email protected]