mysql安装以及2059 - Authentication plugin 'caching_sha2_password' cannot be loaded:报错的解决办法


mysql安装以及2059 - Authentication plugin 'caching_sha2_password' cannot be loaded:报错的解决办法

如果创建mysql的数据库连接报如下错误:2059 - Authentication plugin 'caching_sha2_password' cannot be loaded:

从错误信息可知caching_sha2_password不能加载。

以上报错是由于目前已有的客户端连接软件还不支持Mysql8新增加的加密方式caching_sha2_password,所以我们需要修改用户的加密方式,将其改为老的加密验证方式。

大安装Mysql数据库的主机上登录Mysql对应的用户,上面连接时用的用户为root,所以我们登录root用户。

执行命令

use mysql;

select user,plugin from user where user='root';

可以看到当前用户的加密方式为caching_sha2_password

执行命令

alter user 'root'@'%' identified with mysql_native_password by 'root';

或者
alter user 'root'@''localhost' identified with mysql_native_password by 'root';

将用户的加密方式改为mysql_native_password

执行命令flush privileges使权限配置项立即生效。

再次尝试连接Mysql,连接成功。