用workbench连接MySQL出现Authentication plugin ‘caching_sha2_password’ cannot be loaded的问题,如下图
原因
出现这个问题的原因是由于Navicat和MySQL的版本问题,
mysql8 之前,加密规则是mysql_native_password;
mysql8 之后,加密规则是caching_sha2_password。
解决方法一种是升级Navicat驱动,一种是MySQL的加密规则。
我这里是将MySQL的加密规则改为mysql_native_password
解决方法
1、管理员运行cmd,登录MySQL
执行以下命令,可看到root 加密规则caching_sha2_password。
C:\Windows\System32>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.33 MySQL Community Server - GPL
Copyright (c) 2000, 2023, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use mysql;
Database changed
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
更新用户的密码,并刷新权限。
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
123456是我设置 的密码。
刷新权限
FLUSH PRIVILEGES;
此时使用workbench 连接就可以成功了。