Menu

Sponsored By: Password Angel - Share passwords, API keys, credentials and more with secure, single-use links.

Fixing "Authentication plugin 'caching_sha2_password' cannot be loaded" errors

Summary

You have installed MySQL 8 and are unable to connect your database using your MySQL client (Sequel Pro, HeidiSQL etc). Every attempt to connect using your MySQL client results in the following error

Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found

or

Authentication plugin 'caching_sha2_password' cannot be loaded. The specific module can not be found

Reason

As of MySQL 8.0, caching_sha2_password is now the default authentication plugin rather than mysql_native_password which was the default in previous versions. This means that clients (Sequel Pro, HeidiSQL etc) that rely on the mysql_native_password won't be able to connect because of this change.

Resolution

1) You can, at a server level, revert to the mysql_native_password mechanism by adding the following to your MySQL configuration files

[mysqld]
default_authentication_plugin=mysql_native_password

2) You can, at a user level, revert to the mysql_native_password mechanism via the following process

Open a terminal window and connect to your MySQL instance via the command line

mysql -u [USERNAME] -p

Enter your MySQL password and press enter and you should be logged into your MySQL instance.

Now run the following SQL command, replacing [USERNAME], [PASSWORD] and [HOST] as appropriate.

Note: [HOST] can be the IP address of your computer which would allow access from your computer only or, in the case of a local development environment, you can use % to allow from any host.

ALTER USER '[USERNAME]'@'[HOST]' \
  IDENTIFIED WITH mysql_native_password \
  BY '[PASSWORD]';

or

ALTER USER '[USERNAME]'@'%' \
  IDENTIFIED WITH mysql_native_password \
  BY '[PASSWORD]';

Now you should be able to go back to your MySQL client and connect as normal.

References

Enjoyed this article?

Thank you for reading this article! If you found the information valuable and enjoyed your time here, consider supporting my work by buying me a coffee. Your contribution helps fuel more content like this. Cheers to shared knowledge and caffeine-fueled inspiration!

Buy me a coffee

Originally published at https://chrisshennan.com/blog/fixing-authentication-plugin-cachingsha2password-cannot-be-loaded-errors

Subscribe to my newsletter...

... and receive the musings of an aspiring #indiehacker directly to your inbox once a month.

These musings will encompass a range of subjects such as Web Development, DevOps, Startups, Bootstrapping, #buildinpublic, SEO, personal opinions, and experiences.

I won't send you spam and you can unsubscribe at any time.