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. Following all three steps keeps your site accessible and your credentials secure.
How WordPress connects to your database
WordPress connects to its MySQL database using credentials stored in 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 to match, then update any WordPress user passwords as needed.
Before you begin
- Access to your hosting control panel (cPanel or WHMCS). You need this to manage your MySQL users and databases — 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. Open both your hosting control panel and your File Manager (or FTP client) 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.
- Log in to your hosting control panel.
- Navigate to Databases > MySQL Databases (or MySQL Users) in cPanel.
- Locate the MySQL user associated with your WordPress database.
- Click Change Password next to the relevant user.
- Enter a strong new password and confirm it.
- Click Update (or Change Password) to save.
Tip: If you are unsure which MySQL user is connected to your site, open wp-config.php and check the value of DB_USER.
Tip: Copy your new password to a secure location, such as a password manager, before continuing. You will need it in the next step.
Step 2: Update wp-config.php
Now that your MySQL user password has changed, update wp-config.php so WordPress can reconnect to the database using the new credentials.
- Open your File Manager in the hosting control panel, or connect via FTP/SFTP using a client.
- Navigate to the root directory of your WordPress installation (typically public_html, or a subdirectory if WordPress is installed in a subfolder).
- Locate the file named wp-config.php and open it for editing.
- Find the line that reads:
define( 'DB_PASSWORD', 'your_current_password' ); - 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' ); - Save the file.
- Reload your WordPress site in a browser to confirm the database connection is restored.
Warning: Do not change any other values in wp-config.php unless you intend to. Editing the wrong line can break your WordPress installation.
Using a different CMS?
If your site runs on a CMS other than WordPress (for example, Joomla or Drupal), you will 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 — consult your platform's documentation.
Next steps
- Update your WordPress admin password. Rotate it whenever you rotate your database password. See Resetting Your WordPress Admin Password.
- Reset your cPanel password too. Keeping all hosting credentials fresh tightens overall account security. See How to Reset Your cPanel Password.
- Store new credentials in a password manager. Avoid keeping plain-text copies on your desktop or in email.
Questions? Contact Exact Hosting Support.
Related articles
- Troubleshooting "Error Establishing a Database Connection" — what to do when the connection fails
How helpful was this article?
Thanks for your feedback!
Do you still need help? If so please submit a request here.