MySQL错误:无法加载身份验证插件“caching_sha2_password”。

15

我刚刚在我的macOS v10.13.4上通过Homebrew安装了MySQL Ver 14.14 Distrib 5.7.22。
我运行了以下命令:
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上问。 - spencer7593
在 https://dev59.com/_FUK5IYBdhLWcg3w2y-R 中的指示基本上帮助了我。Sequel Pro 无法处理新密码,将 mysql-password 引擎类型恢复为“旧方式”对我有用。 - Ricky Levi
4个回答

3
所以,我通过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,但这只会让我陷入无休止的错误循环中。


如果你无法让它工作,就节省很多挫败感,安装mariadb。https://mariadb.com/kb/en/library/installing-mariadb-on-macos-using-homebrew/ 第一次就成功了。 - markuscornelius

0

我想这个问题应该是与安装的mysql版本有关。就像上面一样,你应该先找到并杀掉附加在3306端口上的mysqld进程。

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

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

brew upgrade mysql

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

例如:mysql -u root -p [您的密码]


0

重新启动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

在PWD中尝试

关于一个问题。

无法加载身份验证插件“caching_sha2_password”


现在没有运行mysql服务器。mysql_secure_installation正在抛出此错误。我已经尝试了您包含的链接中的每个答案。 - Faheem Hassan Zunjani

0

我在使用Sequel Pro尝试通过SSH连接到安装有MySQL的AWS Ubuntu服务器时遇到了这个错误。

我使用的是非root MySQL用户,但它给了我这个错误。当我使用root用户和密码运行时,它可以正常工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接