How to Fix the Error Establishing a Database Connection?

by | Last Updated Jan 26, 2020 | WordPress | 0 comments

The ‘Error Establishing a Database Connection’ warning on your WordPress website is a fatal error.

This error causes your WordPress website unavailable to your website visitors.

When WordPress is unable to establish a connection to the database, this error happens.

Many things can affect your WordPress database connection, which makes it a bit hard for beginners to troubleshoot.

In this article, you can learn how to fix the Error Establishing a Database Connection in WordPress quickly.

Why Do You See Error Establishing a Database Connection in WordPress?

Incorrect database information in your WordPress settings causes the ‘Error Establishing a Database Connection.’

A corrupt database or an unresponsive database server also throw this error.

What is a Database?

A database is a software that makes it easy to store, organize, and retrieve data into other software.

WordPress utilises a database to store all your content and other data.

Every time someone visits your website, WordPress connects to the database.

For connecting to the database, WordPress requires the following information.

Database Name
Database Username
Database Password
Database Server

WordPress store this information in the wp-config.php file. This wp-config.php file is the WordPress configuration file.

WordPress will fail to connect to your database server if any of these values are incorrect.

With this step by step troubleshooting, let us see how to fix Error Establishing a Database Connection issue in WordPress.

Verify Your WordPress Database Credentials

Wrong database credentials are the usual reason for database connection error in WordPress.

Have you migrated your WordPress site to a new host recently? Then this could be the most likely reason.

The wp-config.php file saves your WordPress database credentials.

This WordPress configuration file holds critical WordPress settings.

To check the values in the wp-config.php file, log in to DirectAdmin control panel.

Click on the File Manager under System Info & Files section.

Now open public_html folder.

Mouse hover on wp-config.php and click on the Edit File.

Take a look at the following lines in your wp-config.php file.

It would be best if you made sure that the information for the Database Name, Database Username, Database Password and Database Server is correct.

You can verify this information from your DirectAdmin dashboard.

Log in to your DirectAdmin account and click on MySQL Management under the Account Manager section.

You can now see the MySQL Management page with all the Databases listed.

From here, click on the database name associated with your WordPress website.

In the Users page, you can take various actions to your database.

Create New User
Add Existing User
Delete User
Change Password
Modify Privileges

Change WordPress Database Password

If you are unsure about the database password or wish to update it, click on the Change Password link.

In this CHANGE PASSWORD pop up, you can Generate Random Password or input a password.

You can toggle hide and show on clicking the eye icon.

You can copy the password to your clipboard as well.

Now click on the Change button, and the database password will update.

Have you confirmed your database name, username, and password?

You can now modify that information in your wp-config.php file if needed.

Now try revisiting your website to see if the database connection error has gone.

Do you still see the error? Then that means something else is incorrect.

Contact Support

All great WordPress hosting companies can support you troubleshoot the problem. Or point you in the correct direction to fix it yourself.

Have you hosted your WordPress website with us?

Then create a support ticket, and we are happy to fix it for you.

Want to See Your WordPress Website Loads in a Second?

We offer a 30 Day Money Back Guarantee, so joining is Risk Free

By Gifty Antony

Gifty is passionate about Web Development and connected with various communities. She loves WordPress.

Check Out These Related Posts

How to Login to Your WordPress Admin (Easy Step)

How to Login to Your WordPress Admin (Easy Step)

Are you new to WordPress and wondering How to log in to my WordPress Admin? Worry not, this is the tutorial for you. It is usual for new users to have difficulty locating their WordPress login URL after installing their first WordPress site. I may have forgotten or...

read more

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *