MySQL passwords do not work after upgrade

This article describes a problem that occurs after a server is upgraded to MySQL 5.6.5 or later, and how to resolve it.

If you are unsure which MySQL version is installed on your server, follow these steps:
  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. In the right sidebar of the cPanel home screen, under GENERAL INFORMATION, click Server Information.
  3. Under Server Information, locate the MySQL Version row to determine the MySQL version installed on the server.
Table of Contents

Problem

When you try to access a database on a server running MySQL 5.6.5 or later the login fails, even though you are using the correct username and password.

For example, if you are running WordPress on your site, you see the following error message:

Error establishing a database connection

Other web applications may display similar messages about database connection errors.

Cause

This problem occurs because MySQL 5.6.5 and later versions use a new hashing method for user passwords. These newer MySQL versions do not support the hash method that was used in older versions of MySQL to store passwords, so logins fail.

Resolution

To resolve this problem, you must delete and recreate the database user. When you do this, MySQL uses the new hash method to store the password, and the database user can log in again.

To do this, follow these steps:

  1. Log in to cPanel.
    If you do not know how to log in to your cPanel account, please see this article.
  2. Open the MySQL Databases tool:
    • If you are using the Jupiter theme, on the Tools page, in the Databases section, click MySQL Databases:

      cPanel - Databases - MySQL Databases icon

    • If you are using the Paper Lantern theme, in the DATABASES section of the cPanel home page, click MySQL Databases:

      cPanel - Databases - MySQL Databases icon

  3. Under Current Users, locate the database user that you want to recreate, and then click Delete.
  4. Click Delete User to confirm the deletion, and then click Go Back.
  5. Under Add New User, in the Username text box, type the username of the user you deleted in step 3.
  6. In the Password text box, type the user password.

    You do not have to create a new password for the user. You can use the previous password if you want to keep the password unchanged. To determine the current password, check your application's configuration files. For example, if you are running WordPress, check the wp-config.php file for database configuration information.
  7. In the Password (Again) text box, retype the user password.

    Alternatively, you can click Password Generator and cPanel generates a random, strong password for you.
  8. Click Create User. cPanel creates the database user using the new hashing method to store the password.

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.