X
X

Select Your Currency

Türk Lirası $ US Dollar
X
X

Select Your Currency

Türk Lirası $ US Dollar

WordPress Error Establishing a Database Connection Definitive Solution

HomepageArticlesWordPress Error Establishing a Database Connec...

Why Does "Error Establishing a Database Connection" Occur?

Seeing all your content disappear with the words "Error establishing a database connection" on a plain white page can be a nightmare. The backbone of WordPress sites is completely built on a database (MySQL). This error generally results from one of two different categories: Incorrect file-sided password settings or a crashed database service on the server side.

Step 1: Verifying wp-config.php Information

When you migrate your hosting package or change your database password for some reason, the connection breaks instantly because WordPress remembers the old password. Go to the root directory where your site is installed (public_html) via cPanel or FTP and open the wp-config.php file. Make sure that the following areas are exactly the same as your information in the cPanel MySQL Databases section:

define('DB_NAME', 'database_name');
define('DB_USER', 'user_name');
define('DB_PASSWORD', 'your_new_password');
define('DB_HOST', 'localhost');

(Note: On some external servers, the DB_HOST part must be entered as an IP address instead of localhost.)

Step 2: Database Repair May Be Required

If you get the "Error Establishing a Database Connection" error only when entering the /wp-admin (admin panel) of the site (while the front end opens), it means your database tables are damaged. To fix this, add the following line to the bottom of your wp-config.php file again:

define('WP_ALLOW_REPAIR', true);

Then go to the yoursite.com/wp-admin/maint/repair.php address from the browser and press the "Repair Database" button. Don't forget to delete this code when the process is finished.

Step 3: Restarting the MySQL Service on the Server

If you are using your own virtual server and your visitor traffic suddenly increases, MySQL may have shut down due to a lack of resources (RAM). In this case, you need to log in with SSH and restart the service:

sudo systemctl restart mysql
or
sudo systemctl restart mariadb

If you want to prevent database crashes and add speed to your site, you can benefit from reliable İyibirNet Turkey VDS server packages reinforced with dedicated hardware.


Top