【问题标题】:MySQL Error: Authentication plugin 'caching_sha2_password' cannot be loadedMySQL 错误:无法加载身份验证插件“caching_sha2_password”
【发布时间】:2020-05-30 11:35:45
【问题描述】:

我刚刚在我的 macOS v10.13.4 上安装了 MySQL Ver 14.14 Distrib 5.7.22 with Homebrew。
我运行了命令:
brew install mysql

安装完成后,按照 Homebrew 的指示,运行命令:
mysql_secure_installation
并返回错误:Error: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found

我尝试了一些方法,例如在 my.cnf 文件中将 default_authentication_plugin 更改为 mysql_native_password,但它仍然抛出相同的错误。

接下来我尝试运行:
mysql_upgrade -u root
我又被抛出了同样的错误mysql_upgrade: Got error: 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found while connecting to the MySQL server Upgrade process encountered error and will not continue.

感谢任何帮助。

【问题讨论】:

  • 这个问题最好在 dba.stackexchange.com 上提出
  • stackoverflow.com/questions/51179516/… 中的说明帮助我基本上 Sequal Pro 无法处理新密码,将 mysql-password 引擎的类型恢复为“旧方式”为我解决了它

标签: mysql macos macos-high-sierra


【解决方案1】:

所以,我通过sudo lsof -i tcp:3306找到了mysqld的运行进程,然后我用sudo kill -9 <PID>杀死了它。

在此之后我再次尝试mysql_secure_installation,但遇到了一个新错误:

错误:无法通过套接字'/tmp/mysql.sock' (61) 连接到本地 MySQL 服务器

在尝试了一些修复以使 mysql.sock 正常工作后,我使用 sudo mysql.server start 启动 MySQL 服务器,然后继续使用 mysql_secure_installation 为 root 用户设置密码。

这终于对我有用了。

注意:Homebrew 要求您在第一次启动 MySQL 服务器之前先执行mysql_secure_installation,但这只会让我陷入无休止的错误循环。

【讨论】:

【解决方案2】:

重新启动 mysql 服务器以使更改生效并尝试通过 mysql 与任何 mysql 客户端连接。

否则使用docker

docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql --default-authentication-plugin=mysql_native_password
mysql -uroot --protocol tcp

Try in PWD

相关的问题。

Authentication plugin 'caching_sha2_password' cannot be loaded

【讨论】:

  • 目前没有运行mysql服务器。 mysql_secure_installation 抛出此错误。我已经尝试了您包含的链接中的每个答案。
【解决方案3】:

我发现这应该是安装的 mysql 版本的问题。和上面一样,你应该先找到然后杀死连接在端口 3306 上的 mysqld 进程

sudo lsof -i tcp:3306
sudo kill -9 <Peocess ID>

然后通过brew升级mysql安装,本例:

brew upgrade mysql

这应该可以解决它。升级后运行 mysql 应该在安装后启动您的服务器。

例如mysql -u root -p [your password here]

【讨论】:

    【解决方案4】:

    我在 Sequel Pro 中尝试通过 SSH 连接到本地安装了 MySQL 的 AWS Ubuntu 服务器时遇到此错误。

    我使用的是非 root MySQL 用户,它给了我这个错误。当我使用 root 用户和密码运行它时,它起作用了。

    【讨论】:

      猜你喜欢
      • 2019-12-25
      • 2020-12-07
      • 2018-10-03
      • 2019-04-14
      相关资源
      最近更新 更多