Mysql Server忘記密碼又失敗的緊急救援

查mysql的log檔發現有個錯誤訊息和 caching_sha2_password 有關係,結果亂設定導致密碼無法登入,用忘記密碼的救法也無效,幸好我的sql有備份,於是決定把mysql全部砍掉重來

apt-get purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*

rm -rf /etc/mysql /var/lib/mysql

apt-get autoremove

apt-get install mysql-server mysql-client

mysql -u root

ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'yourpassword'; exit;

我再回去看log檔時,發現 caching_sha2_password 相關的錯誤也沒了....

用了好幾年才發現有這個錯誤 XD

幸好每天都有備份,備份真的很重要

留言

熱門文章