我刚刚在我的 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.
任何帮助表示赞赏。
小智 5
所以,我找到了 mysqld 的运行进程,sudo lsof -i tcp:3306
然后我使用sudo kill -9 <PID>
.
在此之后,我$ mysql_secure_installation
再次尝试但遇到了一个新错误Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
在尝试了一些让 mysql.sock 工作的修复程序后,我启动了 MySQL 服务器,
$ sudo mysql.server start
然后继续$ mysql_secure_installation
为 root 用户设置密码。
这最终对我有用。
注意:Homebrew 要求你在第一次mysql_secure_installation
启动 MySQL 服务器之前先做,但这让我陷入了无限循环的错误。