错误描述
在使用
Navicat Premium 12
连接MySQL
数据库的时候报错: Authentication plugin ‘caching_sha2_password’ cannot be loaded
错误原因
原因是
mysql8
以前版本的加密规则是mysql_native_password
,但是在mysql8
之后版本的加密规则是caching_sha2_password
。
解决办法
将
mysql
用户登录密码加密规则还原为mysql_native_password
步骤:
1. Windows + CMD
命令窗口,输入命令登录MySQL
mysql -u root -p
输入正确密码登录。
2. 修改加密规则
alter user 'root'@'localhost' identified by 'password' password expire never;
3. 更新登录密码
alter user 'root'@'localhost' identified with mysql_native_password by 'password';
4. 刷新权限
FLUSH PRIVILEGES;
5. 重置密码
alter user 'root'@'localhost' identified by '输入你要修改的登录密码';
操作截图:
重新连接成功: