MySQL 错误:无法加载身份验证插件“caching_sha2_password”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49945649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL Error: Authentication plugin 'caching_sha2_password' cannot be loaded
提问by Faheem Hassan Zunjani
I just installed MySQL Ver 14.14 Distrib 5.7.22 with Homebrew on my macOS v10.13.4.
I ran the command:brew install mysql
我刚刚在我的 macOS v10.13.4 上安装了带有 Homebrew 的 MySQL Ver 14.14 Distrib 5.7.22。
我运行了命令:brew install mysql
After the installation completed, as directed by Homebrew, I ran the command:mysql_secure_installation
and was returned the error: 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
安装完成后,按照 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
I tried a few things like changing default_authentication_plugin to mysql_native_password in the my.cnf file but it still throws the same error.
我尝试了一些事情,比如在 my.cnf 文件中将 default_authentication_plugin 更改为 mysql_native_password,但它仍然抛出相同的错误。
Next I tried running:mysql_upgrade -u root
and I was thrown the same error again 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.
接下来我尝试运行: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.
Any help is appreciated.
任何帮助表示赞赏。
采纳答案by Faheem Hassan Zunjani
So, I found the running process of mysqld by sudo lsof -i tcp:3306
then I killed it using sudo kill -9 <PID>
.
所以,我找到了 mysqld 的运行进程,sudo lsof -i tcp:3306
然后我使用sudo kill -9 <PID>
.
After this I tried mysql_secure_installation
again, but ran into a new error :
在此之后,我mysql_secure_installation
再次尝试,但遇到了一个新错误:
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
错误:无法通过套接字“/tmp/mysql.sock”连接到本地 MySQL 服务器 (61)
After trying a few fixes for getting mysql.sock to work, I started the MySQL server with sudo mysql.server start
then went ahead with mysql_secure_installation
to set password for the root user.
在尝试了一些让 mysql.sock 工作的修复之后,我启动了 MySQL 服务器,sudo mysql.server start
然后继续mysql_secure_installation
为 root 用户设置密码。
This worked for me finally.
这最终对我有用。
Note: Homebrew asks you to first do
mysql_secure_installation
before starting the MySQL server for the first time but that just made me run into endless loop of errors.
注意:Homebrew 要求你在第一次
mysql_secure_installation
启动 MySQL 服务器之前先做,但这让我陷入了无限循环的错误。
回答by Waweru Mwaura
I figured out this should be an issue with the mysql version installed. Just as above you should first find then kill the mysqld process attached on port 3306
我发现这应该是安装的 mysql 版本的问题。就像上面一样,您应该首先找到然后终止连接在端口 3306 上的 mysqld 进程
sudo lsof -i tcp:3306
sudo kill -9 <Peocess ID>
Then upgrade the mysql installation via brew, in this case:
然后通过brew升级mysql安装,在这种情况下:
brew upgrade mysql
This should solve it.Running mysql after the upgrade should start your server after the installation.
这应该可以解决它。升级后运行 mysql 应该会在安装后启动您的服务器。
e.g mysql -u root -p [your password here]
例如 mysql -u root -p [your password here]
回答by Ian
I got this error in Sequel Pro trying to connect over SSH to an AWS Ubuntu server with MySQL installed locally.
我在 Sequel Pro 中遇到此错误,尝试通过 SSH 连接到本地安装了 MySQL 的 AWS Ubuntu 服务器。
I was using a non-root MySQL user and it gave me that error. It worked when I ran it with the root user and password.
我使用的是非根 MySQL 用户,它给了我那个错误。当我使用 root 用户和密码运行它时,它起作用了。
回答by u5602117
Restart the mysql server to take the changes in affect and try connecting via mysql with any mysql client.
重新启动 mysql 服务器以使更改生效并尝试通过 mysql 与任何 mysql 客户端连接。
Otherwise use docker
否则使用码头工人
docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql --default-authentication-plugin=mysql_native_password
mysql -uroot --protocol tcp
Related a question.
相关一个问题。
Authentication plugin 'caching_sha2_password' cannot be loaded