很多使用者在使用Navicat Premium 12連接配接MySQL資料庫時會出現Authentication plugin ‘caching_sha2_password’ cannot be loaded的錯誤。
出現這個原因是mysql8 之前的版本中加密規則是mysql_native_password,而在mysql8之後,加密規則是caching_sha2_password, 解決問題方法有兩種,一種是更新navicat驅動,一種是把mysql使用者登入密碼加密規則還原成mysql_native_password.
這裡用第二種方式 ,解決方法如下
1. 管理者權限運作指令提示符
登陸MySQL(記得添加環境變量)
mysql -u root -p
password: #登入mysql
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; #重新整理權限