How to solve error establishing a database connection in wordpress

How to solve Error Establishing a Database ConnectionWordPress uses a MySQL database in which all data is stored. The error says it was not successful to connect to the database. Fortunately, this error is relatively easy to fix. You can read how to do this in this article.

How to solve error establishing a database connection in wordpress

How to solve error establishing a database connection in wordpress

The error message can arise for various reasons. The most common causes are:

  • The information provided (hostname, database name, username, and/or password) is incorrect
  • The database server is not available, for example, due to busyness or other reasons
  • The database is corrupt

The problem, as indicated earlier, is easy to solve. Follow the steps below.

Hire website maintenance company to fix all your issues

Are the database data correct?

The data used to connect to the database is contained in the wp-config.php file. The file is located in the root (root directory) on the server. The file contains all configuration settings of WordPress and therefore also the database data.

Search for the information below:

The database data is:

DB_NAME – this should contain the name of the database
DB_USER – the name of the database user
DB_PASSWORD – the password of the database user
DB_HOST – the name of the host, usual localhost

Check the data with the data you received from your provider. An easy way to check it is to use PHPMyAdmin and enter the details there. Are you able to log in? Then you know that the data is correct.

Still the error message?

If the database information is correct but the error has not gone away, the database may be corrupt and needs to be repaired. You can check this by logging in to WordPress. Go to the / wp-admin to login. If the database is corrupt, you will get a message here:  “One or more database tables are unavailable. The database may need to be repaired ”.

You can solve this by adding the line below in the wp-config.php file:

define (‘WP_ALLOW_REPAIR’, true);

Click on the Repair or Repair and Optimize Database button. This is why website maintenance is very important to solve on how to solve error establishing a database connection in wordpress

 

Is the error message not gone yet?

The above steps may not have helped. Then it is wise to contact your provider. They can see if there is something wrong with the database server. This can, for example, be offline or very busy.

We are specialized in Website maintenance , need nay help, contact us

Leave a comment

echo "";