How To Fix Database Connection Error in WordPress

August 30, 2017

Blogging and writing are the most common tool to express our thoughts and opinions. The majority of Internet traffic goes to major blogging sites where a common user read write or comment upon the views of the various field. One such major blogging site is '' WordPress ''. Millions of people visit their website to post a blog about the individual personal opinion or a company product or Government organization policy. 

With more than 40 million unique visitors across the world use this platform for their various purposes. Sometimes due to faces some technical problem, one of the common problem user do faces while surfing the internet or the Word Press is about “Error in Establishing a Database connection”. The problem is always time taking if you could not able to find the real reason and the ultimate solution to fix. Let's finds out the possible reason behind the Error in a Database connection.

What are the Common Reasons behind this Problem?

The common reason is behind such error message is unable to establish a proper data base connection. But the real reason behind could be multiple while connecting to your database. Let's look out for some of the possible reasons behind it which are given below:

  • Login credentials for your database are wrong: The database uses some separate login credentials i.e. Username and Password. If those credentials have been changed for whatever reason, your word press website won't be able to access the database with the old credentials.
  • The Database is Corrupted: Any number of thing s could cause your Word Press database to become Corrupted, from Uploading a bad Plugin, to lightning strikes to the server.
  • The Server that hosts your database is down : This might be the main cause that database server is down due to a problem or error on the part of your web hosting company, or you could be experiencing a big traffic spike that your server just couldn't handle or having restraint in loading such large number of request.

Fix the Error Establishing a Database Connection in WordPress

With all the above possibilities, one must narrow down the problem and determine what the real reason behind the issue is. But you can easily fix this problem with the below steps:

Checking Database Username and Password

In order to resolve the database, it's one of the fundamental steps to resolve the issue. One needs to give a closer look at the database in order to resolve the issue. One needs to create a.Php file and store it in your WordPress root folder. This is the same folder where one will find the Wp-config.php file.

Create a new .php file and name it to check.php or whatever one wants. One can easily create the file by opening the WordPress root folder and clicking on the new file on Menu. Once you create the file, it should appear in your root folder in a moment and then right click on it and choose Code Edit or Select it and Right Click on Code Editor on Menu. This will lead to you a blank page and add the following code:


Make sure to replace the local host database root and password with username host and password in wp-config-php file respectively.

Creating New Database User and Password

In order to create a new database on your C panel and access My SQL database. It is also located under database tools, the same tab which it will found on Php, My admin.

  • Clicking on My SQL database. Once the MYSQL Database screen loads, navigate down to where you something like this.
  • Once the MySQL database screens loads, navigate down to where you have MY SQL users. Under this click on the Add new User
  • Enter a new Username and Password and click on the create user.
  • Keep note of these details for Your Wp-config.php file.
  • Once you create the new user then assign the user to your WordPress database.

Resetting the Username and Password of Word Press

One must ensure that your WP-config.php file matches the values in the “ MYSQL Access '' panel of your website application page. If the Username and password don't match, then open your WP-config.php file and edit it to include the values from the “ My SQL Access '' Panel. That's it

In Case, Even after following these procedures one faces issues regarding database connection then Contact Wordpress tech support to fix your problem with the help of wordpress professionals. 


Leave a comment