Error establish a database connection

Last updated December 6th, 2023 00:23

WordPress, like any other content management system, requires two essential components to function properly: FTP and a MySQL database. WordPress uses FTP to store important PHP files, theme templates, plugins, as well as media such as images and files that are displayed on the website as attachments or content. The MySQL database is used by WordPress to store settings, taxonomies, user data, and the complete textual content of pages and posts. Occasionally, you may encounter an error message stating “Error establish a database connection” Today, we will explore why this error occurs and how to fix it.

Error estabilish a databes connection

Error estabilish a databes connection

1.) The database server is not functional.

You will encounter this error almost always when the MySQL server has an issue. It could be overloaded, inaccessible, or turned off. However, the fundamental connection is that the server is not working for some reason, and WordPress cannot establish a connection to it. At this point, the question arises whether you are running the website on your own MySQL server, such as a dedicated VPS where MySQL runs as localhost, or if you have a shared MySQL server provided by a web hosting provider. In the first case, you will need to investigate the cause yourself. In the second case, contact the administrator of your web hosting and MySQL server to inquire about the status of the database.

As a quick test, you can also use the command line and the “telnet” command on port 3306. This is the default port for MySQL databases. The “telnet” command will test the connection to the database, allowing you to see if the database server on the other side is functioning or not.

					telnet 3306

CAUTION: Not every operating system has the “telnet” command functioning by default. For most Windows operating systems, it needs to be installed separately. See the documentation for instructions on how to install it. You can see guide in

2.) You have changed the database password

If you have changed the password for your MySQL database, you need to update the WordPress configuration file as well. WordPress has the database connection settings configured in the wp-config.php file. When you change the password for the MySQL database, the password in this file remains the same. Therefore, it is necessary for you to modify the file and change the password within it. Otherwise, WordPress will attempt to connect to the database with the old password, and the database will deny access.

Follow these steps:

  1. Log in to your FTP using any FTP client.
  2. In the root directory of your WordPress installation, locate the wp-config.php file.
  3. Within the file, find the section that contains the database connection definition and update the password to the new one.

3.) The database server has changed.

This issue typically occurs more often with shared web hosting, where the MySQL server is separate from the web server. Your web hosting provider may have moved the database to a new server, resulting in a change of the target server. In this case, the problem is exactly the same as in the second scenario, with a password change. WordPress will still attempt to connect to the original server, where the database no longer exists. The solution is identical to the second case, with the exception that instead of the password, the section containing the server name needs to be modified.

Error establish a database connection

4.) Damaged tables in the database.

Yes, this can also happen. WordPress stores its data in the database in the form of tables. Each table in the database has its own purpose and meaning. Occasionally, one of the tables may become damaged, causing WordPress to fail in connecting to the database correctly. In simpler terms, it doesn’t receive the correct information to operate properly. In this case, there are two solutions. You can either restore the database content from a backup or attempt to repair the database. The first solution depends on whether you have a database backup or not. That’s why it is always recommended to regularly backup the contents of your database.

The database repair process is as follows:

  1. Log in to your FTP using any FTP client.
  2. Insert the following line define(‘WP_ALLOW_REPAIR’, true) into the wp-config.php file.
  3. In your web browser, enter the address yourdomain.extension/wp-admin/maint/repair.php.

You will see the following page:

Error establish a database connection

Subsequently, WordPress will attempt to repair the database. If it succeeds, the problem is resolved. If not, you will return to the first step of restoring the database from a backup. In extreme cases, you can manually repair the damaged tables.

Error establish a database connection


These are the basic issues that can cause the aforementioned error where WordPress fails to connect to the databas (error establish a database connection). It is important to first consider whether you have made any changes to the password or if your web hosting provider has notified you of any changes or migrations. Then, it is necessary to troubleshoot the error. Typically, this error has simple and quick solutions. However, if you still need assistance, it is advisable to seek help from someone with more experience or contact the support team of your web hosting provider.

More content about WordPress

Whole category is here

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.


Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Upozornit na
0 Komentáře/ů
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje