繁体   English   中英

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

[英]MySQL Error: Authentication plugin 'caching_sha2_password' cannot be loaded

我刚刚在我的 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.

任何帮助表示赞赏。

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

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

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

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

这最终对我有用。

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

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

否则使用码头工人

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

试试手残

相关一个问题。

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

我发现这应该是安装的 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]

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM