Posted at December 23, 2016 at 12:20 pm by Jithin
In this tutorial, we can learn how to fix error establishing database connection in WordPress
WordPress is the most popular CMS (Content Management System). In the web industry, WordPress and its various features are a topic for discussion. There are a number of common errors in WordPress. These errors can be fixed by following some steps. There can be various solutions to these common errors.
In this article, we are going to see how to fix establishing database connection error in WordPress. If you are a WordPress user, you should read this article carefully. Have you ever seen the following page when you tried to access a WordPress website?
This is the screen shot when you see a database error occurred. Let’s see why is this error and what does it mean.
Why This Error?
As the error message indicates, WordPress is unable to establish a successful connection to the database. As we know, WordPress is a database driven application which means it needs at least one database to work. When WordPress fails to connect to the database, this error occurs. Below are a few common issues that may lead to this error.
1) Your database service is down
2) The wrong database and login details
3) A corrupted database
The database service is down
The database service may be down at the moment. If you are using the MySQL databases, check if MySQL is sown. It is possible that the server where your database is stored is down.
As we know the database details such as the database name, username, and database user password are defined in wp-config.php file. If there is some variance in this and the actual details, it can lead you to this error.
The corrupted database
If the database is corrupted, then it can trigger this error.
Steps to fix the error
1) First, we need to make sure that the error is there in both the front end and back end of the website. The back end is your website dashboard. You can access the back-end with the URL: http://yourdomain.tld/wp-admin. If you see the same error in this page also, please move to next step. If you see error like “One or more database tables are unavailable. The database may need to be repaired.”, please proceed with the following.
This means that the database is corrupted. You can fix this by clicking on the Repair Database or Repair and Optimize Database. You are free to select any of these options.
2) Next step is checking the database details provided in the wp-config.php file. First thing you need to do is to open the wp-config.php file. You can use an editor like “vi” from the terminal if you have an SSH access. Usually SSH access will not be available if you are using our shared hosting plans. You can contact support to get SSH access. However, there is alternatives for this. If you are not provided with a shell access, you can open it with the easy to use file manager feature from the cPanel. You can find the file manager under the section “Files”. You need to open the wp-config file. It will be in the location WordPress_root_directory/wp-config.php. Once you’ve opened the file, you can find the below fields in the file.
Go through these lines carefully and you can find the database name, database user, database password and the database host fields. Make sure that the details provided here match the actual detail. If there is any difference, you can set the database name, database user, password from the cPanel interface. You also can update the wp-config.php file with the correct values, but it is not recommended to edit the configuration file if you are not familiar with this.
If you need any further assistance please contact our support department.
You can skip to the end and leave a response. Pinging is currently not allowed.