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.
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.
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-clientSecurity 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.
ERROR 1064: You have an error in your SQL syntax
How to fix "ERROR 1064: You have an error in your SQL syntax" in MySQL
ERROR 1054: Unknown column in field list
Unknown column in field list
ER_WINDOW_RANGE_FRAME_NUMERIC_TYPE (3589): RANGE frame requires numeric ORDER BY expression
RANGE frame requires numeric ORDER BY expression in MySQL window functions
CR_ALREADY_CONNECTED (2058): Handle already connected
How to fix "CR_ALREADY_CONNECTED (2058): Handle already connected" in MySQL
ER_WINDOW_DUPLICATE_NAME (3591): Duplicate window name
How to fix ER_WINDOW_DUPLICATE_NAME (3591) in MySQL window functions