How to Fix Error Establishing a Database Connection” in WordPress
Many beginners face the “Error Establishing a Database Connection” when they are working on the WordPress website. After that, they try their best to correct this error from themselves, but even after many times, they do not succeed. Because they didn’t know how to fix this type of error? They are irritated by fixing this error many times but the didn’t succeed.
If you are irritating from seeing this error on your WordPress website and you need to know about how to fix this error in a simple way. So firstly you have to know about what is “Error Establishing a Database Connection”?
Also, Read About — How to Increase Website Loading Speed and Performance?
What is “Error Establishing a Database Connection”?
Error Establishing a Database Connection is a common WordPress error. which means that your database is not connected to your WordPress website.
So, the database should be connected to your WordPress website for fixing this error. The MYSQL database is not connected to your website because the login credential of your MYSQL database is not correct and you should correct it then the error will be fixed.
Why Error Establishing a Database Connection is occurs on a WordPress website?
This error occurs many times when you are beginners and the main reason for occurring this WordPress error is your database connection not established. That means When your Database is not connected to your WordPress website then this error occurred.
The time of arrival of this error is not fixed this error can occur at any time but mainly this error occurs at 2 times —
- During WordPress Installation
- During WordPress Migration
During WordPress Installation
The Error establishing a database connection occurs when you install the old version of WordPress on your server then this error occurs in your WordPress website.
So you have to download a fresh WordPress Version and then install it on your web server or localhost (Wamp Server or Xampp Server).
During WordPress Migration
When you migrating/transferring/moving your WordPress Website one server to another server or one host to a new host then maybe this error is occurred. If you have not migrated/transfer/move WordPress Website properly and you didn’t connect the new host database to your WordPress website. So then this error occurs.
How to fix “Error Establishing a Database Connection in WordPress?
Fixing the Error Establishing a Database Connection is very simple and we describe with 2 very easy and simplest way-
- Check and correct the Login Credentials of your MYSQL Database in the wp-config.php file.
- Backup and Delete the wp-config.php file.
1. Check and Correct the Login credentials of your MYSQL Database in the wp-config.php file.
When you face “Error Establishing a database connection” on your WordPress website and you have to know the idea about then what you should do that time?.
So you have to check login credentials in the wp-config file on your hosting panel (or wamp and xampp) root directory.
If you have not to get in touch with your hosting panel then you can download and install the WP File Manager Plugin for accessing your website files and folders
Make sure the login credential of your database is correct in wp-config.php file. So go to your hosting panel ( or wamp/ xampp) root directory and download or backup the wp-config.php file and open it and then check the login credentials of your database.
So, check login credential of your database in the wp-config.php file, these areas below —
If these login credential of your database is not correct then correct it by checking on your hosting panel database section and if you are using localhost Wamp server or Xampp server then the login credential is: Database name- “Your Database Name”, Username -“root” and Password — “”(nothing).
Here is MYSQL Database password is nothing because in localhost (xampp or wamp) by default the MYSQL Database password is nothing.
You can check your database name in your hosting panel database section and if you are using local server Xampp or Wamp, then you can go to localhost/Phpmyadmin for checking your database name of you database.
When you correct the login credential of your database in wp-config.php file then save it and then refresh your website by pressing ( Ctrl + F5 ) key of your computer or laptop keyboard.
After that you can see the error establishing a database connection is fixed and your Website run correctly.
2. Backup and Delete the wp-config.php file.
This is the very simplest way to fixing the Error establishing a database connection in WordPress Website.
So if you seeing this error on your WordPress Website then you go to on your hosting panel root directory and download and backup the wp-config file on your computer system. After that delete the wp-config file from the hosting panel (or Wamp or Xampp) root directory.
And then refresh your website by pressing ( Ctrl + F5 ) button of your computer or laptop keyboard. After that you see the installation process of your website, so don’t worry select the language and then click on the continue button.
So, After pressing the continue button you redirect the next page and there is some information about your database that you will need to know and then press the let’s go button.
And, then the next window open where you should fill the database connection details and then click on the “Submit” button.
So now you redirected to a next window where you should click on the “Run the Installation” button.
After that, you got the “Already installed” message in the next window because you installed your WordPress already and then you click the login button.
So, the Error establishing a database connection is already fixed and you can log in here for accessing your WordPress admin dashboard.
If you didn’t log in to your WordPress admin dashboard right now so you can skip this and go to your website and refresh it by pressing the ( Ctrl + F5 ) key of your computer or laptop keyboard.
So then you see your website is running properly and the error is fixed now.
The Error Establishing a Database Connection is fixed now.
So, now you all understand about the WordPress common error the error establishing a database connection and how to solve or fix it without any problem.
These 2 steps are very efficient and 100% practical, easy, and guaranteed way for fixing or solving the error in WordPress.
So try these 2 best easy ways on your website and solve or fix the error quickly. Then tell about this post how you like it and please comment, Is this post helpful for you?