Imagine your life is going smooth. All bills have been paid, and you got a bonus this month. You are spending good quality time with your family. Your boss is very satisfied from your work. You are planning a long holiday with your family. You got cleared from doctor’s therapies. And just for checking up, you open your laptop and connect to WordPress. But suddenly, your screen shows a blank white page having message “error establishing a database connection”. All of your joy and plans will be vanished right away. Because you know that you will not able to connect to your server anymore. You will miss the traffic. Your rankings may get affected. You can lose the opportunities. But, take a deep breath. We are here to help. We ensure that you will be able to establish a database connection in WordPress if you read the whole article here at Live Passion.

Related Terms First:

Before we jump into the main stream, let us take a brief moment to understand the basic terms which you will see in this article.


It is a software which manages the database systems. The word MySQL is derived from the name of the combination of two things. First is “MY” which is taken from the co-founder daughter’s name Michael Widnius, and second part is an abbreviation SQL. It means structured query language. MySQL is basically used to handle web database, but it can be used for warehousing, ecommerce and other purposes.


It is a collection of data which is organized and stored very well. There is many software which perform these tasks. They are known as database software. For easy understandings, you can take the example of phone directory of your area. It is systematically organized data, that’s why we can call it phone directory data base. Similarly, the digital data is required for a site to run. The website first gathers all the data then join it with the user. A database connection in WordPress means that WordPress is trying to connect the user with database.


The word is derived from “hypertext preprocessor”. It is a programming language used for general purposes. It is an open-source platform. You can download it for programming purposes for free. Mostly PHP is used to make static and dynamic web pages. Web applications are also a big field of PHP. A PHP file may contain text, HTML, CSS and Java scripts. It can be used to edit the database. A database connection in WordPress requires PHP in many places.


It is the name of the file. This file contains the information which is stored on WordPress. WordPress keeps these types of files in its configuration. A database connection in WordPress may get disturbed because of some issue in this file. WordPress is a content management system. It requires some credentials to connect the database with these credentials. Wp-config.php contains the name, username, password and database server. If any mistake occurs in these credentials, you will have to face the above-mentioned error. Now let us discuss, what is error establishing a database connection in word press? Why it occurs? And how to fix it?

What is Error Establishing A Database Connection?

According to an assignment writing firm, it is obvious from the statement that it is an error in connection. The two ends which are unable to join are: 1. Your PHP code and 2. Your MySQL. Ig PHP code joins with MySQL, the page will load properly. If you have noticed the error page, you see a blank page there. This is because the server cannot find any information regarding your page.

Why It Occurs?

Until now, you knew that this is the problems in connectivity. For further, this problem may occur due to many reasons. The factors involved in the connectivity are responsible for the error. The simple reason is that you may have entered a wrong login credentials. With the wrong credentials, a database connection in WordPress will not be established. Make sure that you are entering the accurate ones. See the history if you have recently changed the logins. There are many ways to recover the passwords if you have forgotten the existing ones.

The second big and complex reason is corruption in database. It is possible that for some reasons, your main database has got corrupted. May be it happened because of the intrusion of third party. It is possible that your server host is down. Whatever the reason is, you will have to troubleshoot the database so that a database connection in WordPress may establish.

How to Fix Error Establishing a Data Base Connection?

Troubleshoot The Database:

Fixing it through the database is very simple and easy. Thanks to WordPress that allowed an option to establish a database connection in WordPress. Just go to the wp-admin.php file and enable the troubleshooting feature using the following code.

define (‘WP_ALLOW_REPAIR’, true);

With this code, you will enable the troubleshooting and WordPress will automatically locate the error in database if any. There will be two options for repair and repair and optimize. Choose the second one to repair and optimize the database according to your usage. Don’t forget to delete that code from the data base. As anyone can reach your personal database with the existence of that code.

Check The Credentials:

If WordPress does not succeed in establishing a database connection in WordPress, then check the credentials in Wp-config.php file. You will find required data there. Correct the files having name “DB_NAME”, “DB_USER”, DB_PASSWORD”, and “DB_HOST”. Make sure that you provide exact information there, other wise a database connection in WordPress will not be established. You can reset the password by using following code:

<?php $test Connection = mysql_connect(‘localhost’, ‘root’, ‘password’); if (!$testConnection) { die(‘Error: ‘ . mysql_error()); } echo ‘Congratulations! The database connection works!’; mysql_close($testConnection); ?>


Error establishing a database connection is the most irritating error that can occur on WordPress. To establish a database connection in WordPress, we have mentioned some basic techniques we hope they will prove helpful.