Update WordPress database connection string
If your WordPress site is out of sync with your database and displays the following error: "Error Connecting to the Database", you'll need to update the connection strings on your WordPress site.
- You should always backup your site before performing any troubleshooting.
- Locate your database details. (
cPanel / Plesk / Web Hosting / Managed WordPress ). - Edit the wp-config.php for your website. (
cPanel / Plesk / Web Hosting / Managed WordPress / VPS ) - In wp-config.php file, locate the section that looks like this example:
/** The name of the database for WordPress */ define('DB_NAME', 'putyourdbnamehere'); /** MySQL database username */ define('DB_USER', 'usernamehere'); /** MySQL database password */ define('DB_PASSWORD', 'yourpasswordhere'); /** MySQL hostname */ define('DB_HOST', 'localhost');
- Confirm the information in this file matches the database details you found earlier.
- putyourdbnamehere is your MySQL Database Name
- usernamehere is your MySQL User Name
- yourpasswordhere is your MySQL password
- localhost is your MySQL Host Name
- If any of the information in the wp-config.php file doesn't match your database details, then update the file with the correct information.
- Save the updated file.
- Check your website to verify it's back online.