解决MySQL 8 错误:Authentication plugin 'caching_sha2_password' cannot be loaded

向日葵 1年前 ⋅ 2421 阅读

环境

  • ubuntu
  • MySQL 8.0.16
  • Navicat

错误信息

Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found

原因

不是客户端Navicat的原因,是MySQL兼容问题,需要修改数据库的认证方式 MySQL8.0版本默认的认证方式是caching_sha2_password MySQL5.7版本则为mysql_native_password。

官方文档:

https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password

解决办法1

打开系统偏好设置,找到mysql,点击Initialize Database。 输入你的密码。 选择‘Use legacy password‘。 重启mysql服务。 重新使用Navicat链接数据库

解决办法2

用终端连接MySQL,然后执行以下命令:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';
此方法来自:

https://stackoverflow.com/questions/50169576/mysql-8-0-11-error-connect-to-caching-sha2-password-the-specified-module-could-n

解决办法3

修改my.cnf 文件,再重启MySQL:

vim my.cnf
[mysqld]
default_authentication_plugin=mysql_native_password

全部评论: 0

    我有话说: