Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

How to fix MySQL passwords that stop working after an upgrade

This guide helps when your database logins fail right after MySQL was upgraded.

Databases2 min read8 steps4 screenshots

This guide needs root access, so it fits VPS and dedicated server customers.

What goes wrong?

MySQL keeps each user's password in a scrambled form. Scrambling is called hashing. Newer MySQL versions use a different way to scramble. Old programs may not understand the new way. Old accounts may also still hold the old form. After an upgrade, you may see errors like these:

  • Authentication plugin 'caching_sha2_password' cannot be loaded
  • The server requested authentication method unknown to the client
  • Access denied for user

An authentication plugin is the part that checks a password. In MySQL 8, the default plugin is caching_sha2_password. Older apps and PHP versions expect mysql_native_password.

Warning: Take a backup of your databases before you change users. A mistake can lock your site out.

Steps

  1. Log in to your server with SSH. SSH is a safe way to type commands on a remote computer.
  2. Open MySQL as the admin:
    mysql -u root -p
  3. See how each user logs in:
    SELECT user, host, plugin FROM mysql.user;
    This lists each user and its password plugin.
  4. Find the user whose password fails.
  5. Switch that user to the older plugin and set the password again:
    ALTER USER 'myuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 'NewStrongPassword';
    This tells MySQL to use the older method that old apps understand.
  6. Reload the rights:
    FLUSH PRIVILEGES;
  7. Leave with EXIT;
  8. Test the login from your app or with mysql -u myuser -p.
    Screenshot: Test the login from your app or with mysql -u myuser -p .

Remember to put the new password into your app's config file too. For WordPress, that is wp-config.php.

Make it the default for new users

If many users are affected, edit the MySQL config file. It is often /etc/my.cnf or /etc/mysql/my.cnf. Back it up first. Under [mysqld] add:

Screenshot: If many users are affected, edit the MySQL config file. It is often /etc/my.cnf or /etc/my
Screenshot: If many users are affected, edit the MySQL config file. It is often /etc/my.cnf or /etc/my
Screenshot: If many users are affected, edit the MySQL config file. It is often /etc/my.cnf or /etc/my
default_authentication_plugin=mysql_native_password

Then restart MySQL with systemctl restart mysqld (or mysql). In MySQL 8.4 and later this setting changed. Use authentication_policy instead, or fix users one by one.

Tip: A better long-term fix is to update your app and PHP to a version that supports the new plugin.

Need help? Open a support ticket.

Quick recap

  • Upgrades can change how passwords are checked.
  • Look at the plugin column in mysql.user.
  • Use ALTER USER ... mysql_native_password to fix a user.
  • Update the password in your app's config.
  • Back up first.