How to fix the error in database connection for WordPress

Last modified by Stephanie Azarias on 2015/09/30 15:43

Note:  

Before you make any database changes, make sure you have sufficient backups.

Why do you get this error?

You are getting this error because WordPress is unable to establish a database connection. Now the reason why WordPress is unable to establish a database connection can vary. It could be that due to the following reasons.

  • Your database login credentials are wrong or have been changed
  • Your database has been corrupted
  • You do not have a database uploaded on your account

Checking the WP-Config file

Before proceeding, make sure that you have uploaded your database via Cpanel or phpMyAdmin.

WP-Config.php is where you specify the details for WordPress to connect your database. If you changed your root password, or the database user password, then you will need to change this file as well. First thing you should always check is if everything in your wp-config.php file is the same.

  1. define('DB_NAME', 'database-name');
  2. define('DB_USER', 'database-username');
  3. define('DB_PASSWORD', 'database-password');
  4. define('DB_HOST', 'localhost');

You can confirm the the details above by navigating to mysql database.png

The following image show an example of how you can verify the database name and the  database user.

Image 1.png

Note:

Remember your 'DB_Host' value might not always be localhost. Depending on the server where your site is currently hosted.

In GWHS Staging server:

define('DB_HOST', 'localhost');

In GWHS Production 01 server:

define('DB_HOST', 'gwhs-db1.i.gov.ph');

In GWHS Production 02 server:

define('DB_HOST', 'gwhs-db2.i.gov.ph');

If everything in this file is correct (make sure you check for typos) but you still encounter the error, try re-uploading your database.

GWHS Helpdesk

If the error on your database connection still persists, you may contact the ICT Office through the following details:

email: helpdesk@i.gov.ph

Or create a ticket on http://helpdesk.i.gov.ph and our technical staff will provide you assistance.

Tags:
Created by Belgiun Bryan Madriaga on 2015/04/07 10:54