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

环境

  • macOS 10.14.6 (18G87)
  • 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

借鉴文档:
https://blog.51cto.com/fengfeng688/2147169

解决办法1

  1. 打开系统偏好设置,找到mysql,点击Initialize Database。
  2. 输入你的密码。
  3. 选择‘Use legacy password‘。
  4. 重启mysql服务。
  5. 重新使用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

 

时间:2020-12-31 | 分类:技术文摘 | 标签: mysql 
评论列表
暂无评论
发表评论
昵称
邮箱
内容