15

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

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

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.

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.

Any help is appreciated.

  • This question might better be asked on dba.stackexchange.com – spencer7593 Apr 20 '18 at 16:17
  • Instructions in https://stackoverflow.com/questions/51179516/sequel-pro-and-mysql-connection-failed/ helped me basically Sequal Pro couldn't handle the new password, reverting the type of mysql-password engine to "old way" solved it for me – Ricky Levi Feb 15 '22 at 11:22

4 Answers4

3

So, I found the running process of mysqld by sudo lsof -i tcp:3306 then I killed it using sudo kill -9 <PID>.

After this I tried mysql_secure_installation again, but ran into a new error :

Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (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.

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.

Wahyu Kristianto
  • 8,719
  • 6
  • 43
  • 68
  • If you can't get this to work, save yourself a lot of frustration and just install mariadb. https://mariadb.com/kb/en/library/installing-mariadb-on-macos-using-homebrew/ Worked first time – markuscornelius Sep 08 '18 at 16:25
0

Restart the mysql server to take the changes in affect and try connecting via mysql with any mysql client.

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

Try in PWD

Related a question.

Authentication plugin 'caching_sha2_password' cannot be loaded

井上智文
  • 1,905
  • 17
  • 14
  • There is no mysql server running right now. The mysql_secure_installation is throwing this error. I have already tried every answer in the link you have included. – Faheem Hassan Zunjani Apr 20 '18 at 17:02
0

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

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

Then upgrade the mysql installation via brew, in this case:

brew upgrade mysql

This should solve it.Running mysql after the upgrade should start your server after the installation.

e.g mysql -u root -p [your password here]

Waweru Mwaura
  • 247
  • 1
  • 7
0

I got this error in Sequel Pro trying to connect over SSH to an AWS Ubuntu server with MySQL installed locally.

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.

Ian
  • 1,746
  • 1
  • 15
  • 28