Update WordPress Database Connection String

In case your WordPress website is out of sync with database, then it will display the following error: “Error Connecting to the Database”, there you need to update connecting strings on your WordPress site:

  • You should always back up 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)
/** The name of the database for WordPress */
define('DB_NAME', 'yourdatabasename');
/** MySQL database username */
define('DB_USER', 'yourusername');
/** MySQL database password */
define('DB_PASSWORD', 'yourpassword');
/** MySQL hostname */
define('DB_HOST', 'yourhostname');

$table_prefix  = 'yourtableprefix';
  • Confirm the information in this file matches the database details you found earlier.
  • Replace your database name with your MySQL Database Name
  • Replace your username with your MySQL User Name
  • Replace your password with your MySQL password
  • Replace your hostname with your MySQL Host Name
  • Replace your table prefix with your Table Prefix
  • 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.