[MySQL] MySQL InternalError: 1251, u’Client does not support authentication protocol requested by server; consider upgrading MySQL client

某次在local測試時,因為要新增package而重新build了一次docker。
後來更新get-pip出現錯誤訊息如下:

InternalError: (1251, u'Client does not support authentication protocol requested by server; consider upgrading MySQL client')


客戶端不支持服務器請求的身份驗證協議;請考慮升級MySQL客戶端

目前是使用python2.7,MySQL 8.0.23,
不推薦將MYSQL降級,可以通過在創建數據庫時告訴MySQL服務器使用舊版身份驗證插件來實現此目的。

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
flush privileges;

如果不行的話,將@’localhost’拿掉,再重新執行一次,下方還有其他指令,可嘗試以下指令擇一試看看。

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
FLUSH PRIVILEGES; # 最後一定要加這段

我是將@’localhost’拿掉後,才成功的。若失敗的話,請參考下方連結,內有許多解決方式。
參考連結:stackoverflowMysql 解決1251

發佈留言