How to Fix Authentication Plugin Error in MySQL
mysql_native_password using the command ALTER USER 'username'@'host' IDENTIFIED WITH mysql_native_password BY 'password'; and then flushing privileges.Why This Happens
This error happens because MySQL server and client use different authentication plugins. For example, MySQL 8.0 uses caching_sha2_password by default, but some clients only support mysql_native_password. When you try to connect, MySQL rejects the login due to this mismatch.
mysql -u root -p -- Then trying to connect to a user created with default plugin CREATE USER 'user1'@'localhost' IDENTIFIED BY 'password'; -- This user uses caching_sha2_password by default mysql -u user1 -p -- Connection fails with error:
The Fix
Change the user's authentication plugin to mysql_native_password which is widely supported. This is done by running an ALTER USER command and then flushing privileges to apply changes.
ALTER USER 'user1'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES;
Prevention
To avoid this error in the future, always specify the authentication plugin when creating users if you know your client compatibility. Keep your MySQL client updated to support the latest plugins. Also, check your MySQL server version and client compatibility before connecting.
- Use
mysql_native_passwordfor older clients. - Update clients to support
caching_sha2_password. - Test connections after user creation.
Related Errors
Other similar errors include:
- ERROR 1045 (28000): Access denied for user - usually wrong password or user host mismatch.
- Client does not support authentication protocol requested by server - similar plugin mismatch.
- Authentication plugin 'sha256_password' cannot be loaded - missing client support for that plugin.
Fixes usually involve updating client, changing user plugin, or adjusting server settings.