Updating Your MySQL Database Password and WordPress Credentials

This article walks you through the full process of changing your MySQL database user password, keeping your wp-config.php file in sync, and updating your WordPress admin and user passwords, so your site stays accessible and your credentials stay secure.

How WordPress Connects to Your Database

WordPress connects to its MySQL database using credentials stored in a file called wp-config.php, located in the root directory of your WordPress installation. This file contains your database name, username, and password. If you change your MySQL database password in your hosting control panel without updating wp-config.php to match, WordPress will lose its database connection and your site will go down.

Updating your password is a three-part process: change it at the database level, update the config file, then update any WordPress user passwords as needed.

Before You Begin

  • Access to your hosting control panel (cPanel or WHMCS). You'll need this to manage your MySQL users and databases. You need to be able to access the cPanel account, either via external login or the auto login in your client account.
  • FTP/SFTP credentials or File Manager access. Required to edit your wp-config.php file.
  • WordPress admin credentials. Needed to update WordPress user passwords through the dashboard.

Warning: Changing your database password and failing to update wp-config.php immediately will cause your WordPress site to display a database connection error. Have both tabs open before you begin.


Step 1: Update Your MySQL User Password

This step changes the password for the MySQL database user that WordPress uses to connect to your database.

  1. Log in to your hosting control panel.
  2. Navigate to Databases > MySQL Users in cPanel.
  3. Locate the MySQL user associated with your WordPress database. Note: If you're unsure which user is connected to your site, check your wp-config.php file for the value in DB_USER.
  4. Click Change Password next to the relevant user.
  5. Enter a strong new password and confirm it.
  6. Click Update (or Change Password) to save.

Tip: Copy your new password to a secure location (such as a password manager) before proceeding, you'll need it in the next step.


Step 2: Update wp-config.php

Now that your MySQL user password has changed, you need to update the wp-config.php file so WordPress can reconnect to the database using the new credentials.

  1. Open your File Manager in the hosting control panel, or connect via FTP/SFTP using a client.
  2. Navigate to the root directory of your WordPress installation (typically public_html or a subdirectory if WordPress is installed in a subfolder).
  3. Locate the file named wp-config.php and open it for editing.
  4. Find the line that reads:
    define( 'DB_PASSWORD', 'your_current_password' );
  5. Replace your_current_password with the new password you set in Step 1. The updated line should look like:
    define( 'DB_PASSWORD', 'your_new_password' );
  6. Save the file.

Warning: Do not change any other values in wp-config.php unless you intend to. Editing the wrong line can break your WordPress installation.

  1. Reload your WordPress site in a browser to confirm the database connection is restored.

Using a Different CMS?

If your site runs on a CMS other than WordPress (such as Joomla, Drupal, or another platform), you'll need to update the equivalent database configuration file for that platform after changing your MySQL password. The location and name of this file varies by CMS.

Additional Resources

Back to top

How helpful was this article?

Thanks for your feedback!

Do you still need help? If so please submit a request here.