最近刚装 MySql 8.019, 但使用客户端工具Navicat Premium 12 连接 MySql数据库时,连接失败,报错如下:
2059 - Authentication plugin 'caching_sha2_password' cannot be loaded:The specified module could not be found.
MySql 8.0.19安装时, 身份验证方式有提到,8.0以上版本新增插件(caching_sha2_password), 原来的身份验证插件为(mysql_native_password)。
而客户端工具Navicat Premium12 中识别不了新的身份验证插件(caching_sha2_password),因此,我们将mysql用户使用的 登录密码加密规则 还原成 mysql_native_password,即可登陆成功。
- 使用 MySql 数据库自带的命令行客户端工具 ,
路径:开始 -- MySQL-- MySQL Server 8.0 -- MySQL 8.0 Command Line Client -- 双击- 登录数据库,Enter password :root密码
- 使用数据库,mysql> use mysql
use mysql
4. 从数据库的user表中查询 mysql 用户原来使用的身份验证插件
mysql> select user,host,plugin,authentication_string from user;
select user,host,plugin,authentication_string from user;
5. 可以看到 root 的 plugin 是 'caching_sha2_password'
6. 将 root 使用的身份验证插件 替换为之前版本使用的 mysql_native_password 。
mysql> alter user 'root'@'localhost' identified with mysql_native_password by '112233';
alter user 'root'@'localhost' identified with mysql_native_password by '112233';
从数据库的user表中再次查询 mysql 用户使用的身份验证插件
mysql> select user,host,plugin,authentication_string from user;
root 的 plugin 现在是 'mysql_native_password'
修改成功后再次使用客户端工具 Navicat Premium12 。Mysql连接正常,可以使用。