How to Fix the Error Establishing a Database Connection?

by | Last Updated Jun 12, 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.’

How to Fix the Error Establishing a Database Connection? 1

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.

How to Fix the Error Establishing a Database Connection? 2

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

Now open public_html folder.

How to Fix the Error Establishing a Database Connection? 3

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.

[php]define( ‘DB_NAME’, ‘database_name_here’ );
/** MySQL database username */
define( ‘DB_USER’, ‘username_here’ );
/** MySQL database password */
define( ‘DB_PASSWORD’, ‘password_here’ );
/** MySQL hostname */
define( ‘DB_HOST’, ‘localhost’ );[/php]

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.

How to Fix the Error Establishing a Database Connection? 4

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

How to Fix the Error Establishing a Database Connection? 5

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.

How to Fix the Error Establishing a Database Connection? 6
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.

How to Fix the Error Establishing a Database Connection? 7

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.

We engineered our cloud infrastructure with Performance, Speed, Scalability, and Security in mind.

That’s why we built Rovity with AWS, CloudLinux OS, DirectAdmin, and LiteSpeed Web Server.

Come and experience the next generation of shared hosting on the cloud

By Gifty Antony

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

Check Out These Related Posts

How to Improve WordPress With Better TTFB

How to Improve WordPress With Better TTFB

Today we will discuss how TTFB (Time to First Byte) impacts you and how to reduce it. TTFB is commonly an overlooked performance metric, but it should be considered when testing your site's speed. We often focus on front-end performance and optimizations when it comes...

read more



Submit a Comment

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