How to fix CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loaded in MySQL
Error 2059 occurs when MySQL client cannot locate or load a required authentication plugin library. This typically happens with caching_sha2_password after MySQL 8.0 changes or when the plugin directory is misconfigured.
Quick fix
Fixes CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loaded
SELECT user, host, plugin FROM mysql.user WHERE user = 'your_username';- Verify which authentication plugin is required
- Update your MySQL client libraries
- Change user to mysql_native_password authentication
- Specify the plugin directory explicitly
SELECT user, host, plugin FROM mysql.user WHERE user = 'your_username';CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loaded
What this error means
Error 2059 (CR_AUTH_PLUGIN_CANNOT_LOAD) indicates that the MySQL client cannot load a required authentication plugin. This is a client-side error that occurs when the shared library file for an authentication plugin (such as caching_sha2_password, mysql_native_password, or dialog plugins) cannot be found or accessed by the client application. The error became particularly common after MySQL 8.0 changed the default authentication plugin from mysql_native_password to caching_sha2_password. Many older client libraries and applications were not built with support for the newer authentication method. Additionally, MySQL 9.0 removed mysql_native_password from built-in methods, converting it to a dynamically loadable plugin, which can cause this error if the plugin file is missing. The MySQL client searches for plugin libraries in specific directories, and if the installation is in a non-standard location or the plugin directory is not correctly configured, the client will fail to load the required plugin and throw this error.
Typical symptoms
- Connection attempts fail with "Authentication plugin 'X' cannot be loaded" message
- Error code 2059 or HY000 appears in connection errors
- Applications that worked with older MySQL versions fail to connect after upgrade
- MySQL Workbench or other GUI tools cannot establish connections
- Legacy applications using older database drivers fail to authenticate
Common causes
- MySQL 8.0+ using caching_sha2_password while client expects mysql_native_password
- Plugin library file missing from the MySQL client plugin directory
- Outdated MySQL client libraries that do not support newer authentication plugins
- MySQL installed in non-standard location without specifying plugin directory
- MySQL 9.0+ client missing mysql_native_password plugin file (now dynamically loaded)
- Application using old database connectors (PHP, Python, Node.js) incompatible with caching_sha2_password
How to fix "CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loaded"
Check the authentication plugin for the user account:
SELECT user, host, plugin FROM mysql.user WHERE user = 'your_username';This shows which authentication plugin (mysql_native_password, caching_sha2_password, etc.) the user is configured to use.
The most reliable fix is updating your database drivers and client libraries:
For Python:
pip install --upgrade mysql-connector-python
# or
pip install --upgrade PyMySQLFor Node.js:
npm install mysql2@latestFor PHP:
# Ensure you have mysqlnd (native driver) enabled
php -m | grep mysqlndFor Java:
Update your MySQL Connector/J to version 8.0.13 or later in pom.xml or build.gradle.
Modern connectors support caching_sha2_password authentication.
If updating clients is not possible, change the user's authentication plugin:
ALTER USER 'your_username'@'your_host'
IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;Replace 'your_username', 'your_host', and 'your_password' with actual values. This allows older clients to connect.
If MySQL is installed in a non-standard location, specify the plugin directory:
Command line:
mysql --plugin-dir=/path/to/mysql/lib/plugin -u username -pIn my.cnf or my.ini:
[client]
plugin-dir=/usr/lib/mysql/pluginCommon plugin directory locations:
- Linux: /usr/lib/mysql/plugin or /usr/lib64/mysql/plugin
- macOS: /usr/local/mysql/lib/plugin
- Windows: C:\Program Files\MySQL\MySQL Server X.X\lib\plugin
To make all new users use mysql_native_password by default, edit MySQL configuration:
In my.cnf (Linux/macOS) or my.ini (Windows):
[mysqld]
default_authentication_plugin=mysql_native_passwordRestart MySQL service:
# Linux
sudo systemctl restart mysql
# macOS
brew services restart mysql
# Windows
net stop MySQL80
net start MySQL80This only affects newly created users. Existing users must be altered individually.
For MySQL 9.0+, mysql_native_password is a dynamically loadable plugin. Install it if missing:
Check if plugin file exists:
# Linux/macOS
ls -la /usr/lib/mysql/plugin/authentication_ldap_simple.so
ls -la /usr/lib/mysql/plugin/mysql_native_password.so
# Windows
dir "C:\Program Files\MySQL\MySQL Server 9.0\lib\plugin\mysql_native_password.dll"If missing, reinstall MySQL client:
# Homebrew (macOS)
brew reinstall mysql-client
# APT (Ubuntu/Debian)
sudo apt-get install --reinstall mysql-client
# YUM (RHEL/CentOS)
sudo yum reinstall mysql-community-clientAdvanced notes
Security Considerations:
While downgrading to mysql_native_password resolves compatibility issues, it uses less secure SHA-1 hashing compared to caching_sha2_password's SHA-256. For production environments, prioritize upgrading client libraries over downgrading authentication methods.
MySQL Workbench 8.0.40 Bug:
There is a known regression in MySQL Workbench 8.0.40 that causes authentication plugin errors. If you upgraded to this version and cannot connect, downgrade to version 8.0.38 or wait for a patched release.
Connection String Parameters:
Some drivers allow specifying the authentication plugin in the connection string:
mysql://user:pass@host/db?authPlugin=mysql_native_passwordPlugin Search Order:
MySQL searches for plugins in this order:
1. Directory specified by --plugin-dir option
2. Directory named by plugin_dir system variable
3. Built-in plugins (server-side only)
Docker and Containers:
When running MySQL in Docker, ensure your application container has compatible MySQL client libraries. MySQL 8.0 images use caching_sha2_password by default. You can override this:
environment:
MYSQL_ROOT_PASSWORD: rootpass
command: --default-authentication-plugin=mysql_native_passwordTesting Plugin Availability:
To check which plugins are available on your client, inspect the plugin directory or check MySQL documentation for your specific client version. Not all plugins are available on all platforms.
Frequently asked questions
- What does "CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loa" mean?
- Error 2059 (CR_AUTH_PLUGIN_CANNOT_LOAD) indicates that the MySQL client cannot load a required authentication plugin. This is a client-side error that occurs when the shared library file for an authentication plugin (such as caching_sha2_password, mysql_native_password, or dialog plugins) cannot be found or accessed by the client application. 0 changed the default authentication plugin from mysql_native_password to caching_sha2_password.
- How do I fix "CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loa"?
- Error 2059 occurs when MySQL client cannot locate or load a required authentication plugin library. This typically happens with caching_sha2_password after MySQL 8.0 changes or when the plugin directory is misconfigured.
- What causes "CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loa"?
- MySQL 8.0+ using caching_sha2_password while client expects mysql_native_password Plugin library file missing from the MySQL client plugin directory Outdated MySQL client libraries that do not support newer authentication plugins
- Is the "CR_AUTH_PLUGIN_CANNOT_LOAD (2059): Authentication plugin cannot be loa" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐MySQL Official Documentation
- ๐dev.mysql.com - caching sha2 pluggable authentication(Official Docs)
- ๐
- ๐
- ๐github.com - 419(GitHub)
- ๐