使用Navicat 12连接MySQL 8.0时,出现了2059的错误2059 - authentication plugin 'caching_sha2_password' cannot be loaded:
。原因是加密规则不同导致的
1. 用命令行登录数据库
mysql -u root -p
2. 进入mysql数据库
mysql > use mysql;
3. 查看账号加密规则
mysql > select Host,User,plugin from mysql.user;
+-----------+------------------+-----------------------+
| Host | User | plugin |
+-----------+------------------+-----------------------+
| % | root | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | caching_sha2_password |
+-----------+------------------+-----------------------+
4. 修改加密规则
#更改加密方式
ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
#更新用户密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
#刷新权限
FLUSH PRIVILEGES;
这里可以根据自己的账号来判定
- root: 连接的账号
- localhost: 本地连接,如果是外网连接,修改为 ‘%’
- password: 账号对应的密码