Reasons & Solution for the error – Error Establishing Database connection
If you are facing this error – Error Establishing Database connection, don’t be very surprised as this is a very common error. Sometimes it is due your mistake and sometimes due to server issues. Here are the major reasons and solutions to this error :
- You might have migrated your website recently to new domain or hosting – If you have recently migrated your website to a new domain or hosting, you might be facing this error due to your mistake. You might have not properly inserted the database in formation in the wp_config.php file. Please follow the following steps to troubleshoot and resolve this error:
Step 1 – Open file manager in your cPanel. Reach to the file wp_config.php. If your installation is in the root directory, you will find it in public_html folder itself.
Step 2 – Search for the following piece of code :
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘database_name_here’);/** MySQL database username */
define(‘DB_USER’, ‘username_here’);/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here’);/** MySQL hostname */
Step 3 – You should enter the database credentials properly in the given areas :
- In define(‘DB_NAME’, ‘database_name_here’) enter Database name in place of
- In define(‘DB_USER’, ‘username_here’) enter Database User name in place of
- In define(‘DB_PASSWORD’, ‘password_here’) enter Database user’s password in place of Most of the time you might have misplaced it or forgot it. So go to the mySQL databases section of you cPanel and reset it.
- In define(‘DB_HOST’, ‘localhost’), most of the times localhost is the value to be left as it is, but sometimes as per your server configuration it might be the IP address of your server. It is very rare mostly if you have setup your own server.
If you have put up the details correctly, your website should be working very fine now.
- Some disk of the server might be down where the databases are stored – This is the problem from your hosting provider side. Some hosting providers keep you files and database on different disks. If the disk where your database is located is down, your files will not be able to connect to your database and you will face this error. Connect to your hosting service provider for this issue.