問題
使用 Navicat 連接 MySQL 數(shù)據(jù)庫時泉坐,出現(xiàn)以下報錯提示:
2059 - authentication plugin 'caching_sha2_password' cannot be loaded...
這個報錯崇棠,中文意思就是:權(quán)限插件 caching_sha2_password
不能被加載
通過查閱 MySQL 的官方參考文檔,我們看到這樣的一段描述:
- In MySQL 5.7, libmysqlclient uses as its default choice either mysql_native_password or the plugin specified through the MYSQL_DEFAULT_AUTH option for mysql_options().
- When a 5.7 client tries to connect to an 8.0 server, the server specifies caching_sha2_password as its default authentication plugin, but the client still sends credential details per either mysql_native_password or whatever is specified through MYSQL_DEFAULT_AUTH.
從這里掏愁,我們就明白了:
- 8.0 以前的默認身份驗證插件是
mysql_native_password
- 8.0 以后的默認身份驗證插件是
caching_sha2_password
這里會報錯的原因在上面也提到了:5.7 的客戶端去連接 8.0 的服務(wù)端,因為默認的身份驗證插件不同,故會造成插件不能加載的錯誤
說明一下:目前大多數(shù)的 MySQL 客戶端都還沒有升級為 8.0 的認證方式狸涌,故像 Navicat、Sequel Pro础芍、SQLyog 等這些常用的連接工具杈抢,都有可能出現(xiàn)這個問題
解決
將 MySQL 8.0 的身份認證插件改回為 mysql_native_password
-
修改 身份認證插件為
mysql_native_password
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
-
刷新權(quán)限
FLUSH PRIVILEGES;
OK,現(xiàn)在再用 Navicat 去連接 MySQL 便可以成功了