解决数据库连接时2059 - Authentication plugin 'caching_sha2_password' cannot be loaded报错
问题如下:
在Navicat里面连接数据库时直接就出现报错2059 - Authentication plugin ‘caching_sha2_password’ cannot be loaded
从错误信息可知caching_sha2_password不能加载。以上报错是由于目前已有的客户端连接软件还不支持Mysql8新增加的加密方式caching_sha2_password,所以我们需要修改用户的加密方式,将其改为老的加密验证方式。安装Mysql数据库的主机上登录Mysql对应的用户,上面连接时用的用户为root,所以我们登录root用户。
一吨操作:
1.以管理员身份打开dos命令, 输入
mysql -u root -p
登录服务器(没有配置环境变量的朋友请移步博客:https://blog.****.net/David_Aulier/article/details/105888619
)
2.输入:
use mysql;
使用 msyql 系统数据库
3. 输入:
select user, plugin from user where user=‘root’;
查询 user 数据库中的 user,plugin 表
这时可以看到当前用户的加密方式为:caching_sha2_password
4.输入:
alter user ‘root’@‘localhost’ identified with mysql_native_password by ‘[email protected]’;
注意:后面那个 [email protected] 是更改后的密码,这里只是举栗,不想改密码可以不用后面那句 by ‘[email protected]’ ,也可以把[email protected]改为自己想改的密码,记住,这个后面登录服务器要用到的
如果出现上图所示样子,就算成功了吧!这时回到Navicat测试一下,如下图:.
一秒连接成功过!