天天看點

linux環境下的docker安裝mysql8.0 本地連接配接報 Authentication plugin 'caching_sha2_password' cannot be loaded

在虛拟機linux環境的docker中暗轉mysql的最新版本,安裝之後的版本是8.0,然後在本地電腦上用navicate連接配接mysql,提示錯誤

linux環境下的docker安裝mysql8.0 本地連接配接報 Authentication plugin 'caching_sha2_password' cannot be loaded

這個錯誤是預料之中的,以前在本地連接配接遇到過很多次,因為隻需要簡單的執行兩個指令就解決了

ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;#更新一下使用者的密碼 ‘password’ 為自己mysql root賬戶的密碼

FLUSH PRIVILEGES; #重新整理權限

但是這次失效了,實驗了好多次還是不成功。

執行上面兩個指令之前

linux環境下的docker安裝mysql8.0 本地連接配接報 Authentication plugin 'caching_sha2_password' cannot be loaded

執行上面兩個指令之後

linux環境下的docker安裝mysql8.0 本地連接配接報 Authentication plugin 'caching_sha2_password' cannot be loaded

發現ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;這個指令隻會修改本地的,另外一個root使用者沒有修改,host為%的root資料才是外網位址ip客戶連接配接的使用者;

然後就執行ALTER USER ‘root’@’%’ IDENTIFIED WITH mysql_native_password BY ‘password’;這個指令。

執行之後

linux環境下的docker安裝mysql8.0 本地連接配接報 Authentication plugin 'caching_sha2_password' cannot be loaded

然後本地navicate才顯示連接配接成功。

linux環境下的docker安裝mysql8.0 本地連接配接報 Authentication plugin 'caching_sha2_password' cannot be loaded

第一次寫部落格有點小激動,不過因為這個問題出現太多次了,有必要記錄一下。