MySQL 連接出現 Authentication plugin 'caching_sha2_password' cannot be loaded
阿新 • • 發佈:2022-12-09
1、問題描述:
今天在使用Navicat Premium 12連線MySQL資料庫時會出現Authentication plugin 'caching_sha2_password' cannot be loaded的錯誤。
2、原因分析
原因是mysql8 之前的版本中加密規則是mysql_native_password,而在mysql8之後,加密規則是caching_sha2_password;
3、解決方法
把mysql使用者登入密碼加密規則還原成mysql_native_password
.
操作如下:
(1)1管理員許可權執行命令提示符,登陸MySQL
mysql -u root -p
password:
(2)修改賬戶密碼加密規則並更新使用者密碼
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #修改加密規則
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下使用者的密碼
(3)重新整理許可權並重置密碼
FLUSH PRIVILEGES; #重新整理許可權
mysql> show variables like 'default_authentication_plugin';+-------------------------------+-----------------------+ | Variable_name | Value | +-------------------------------+-----------------------+ | default_authentication_plugin | caching_sha2_password | +-------------------------------+-----------------------+ 1 row in set (0.01 sec) mysql> select host,user,plugin from mysql.user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | % | root | caching_sha2_password | | localhost | mysql.infoschema | mysql_native_password | | localhost | mysql.session | mysql_native_password | | localhost | mysql.sys | mysql_native_password | | localhost | root | caching_sha2_password | +-----------+------------------+-----------------------+