WordPress Error Establishing Database Connection Error
This guide explains how to solve the “Error Establishing Database Connection” error that is common on WordPress sites.
The goal is to quickly find the source of the problem and make the site accessible again.
What Will You Learn in This Guide?
- Check server and MySQL status
- Verify WordPress database information
- Repair broken WordPress tables
- Preventing the error from occurring again
Possible Error Causes
This error usually occurs due to one of the following situations:
- MySQL service has stopped or there is a lack of memory
- Database information in file
wp-config.phpis incorrect - WordPress database tables are corrupted
Requirements
- A server with WordPress installed
- SSH and
sudoaccess - Database username, password and database name
1. Step 1: Checking Server and MySQL Status
- Connect to the server via SSH:
ssh kullanici@sunucu_ip
- This command allows you to connect to the server remotely.
- Check that the MySQL service is running:
sudo netstat -plt
- If you see mysqld in the output, it means MySQL is running.
- If MySQL is not running, start it:
sudo systemctl start mysql
1.1 Memory Problem Checking
- MySQL may have shut down due to memory issues. Examine the logs:
zgrep -a "allocate memory" /var/log/mysql/error.log*
- This command searches for memory errors.
If you are seeing memory errors, you need to move to a server with higher RAM.
2. Step: Checking Database Login Information
- Find the wp-config.php file:
sudo find / -name "wp-config.php"
- Open the file with the editor:
sudo nano /var/www/html/wp-config.php
- Check the following values:
define('DB_NAME', 'veritabani_adi');
define('DB_USER', 'veritabani_kullanici');
define('DB_PASSWORD', 'veritabani_sifre');
- If the information is not correct, correct it and save it.
2.1 Connection Testing from Command Line
- Test that the information actually works:
mysqlshow -u veritabani_kullanici -p
- This command verifies user access.
If the database is listed, the information is correct.
3. Step: Repair WordPress Database
- In some cases, the database may be corrupted.
- Add the following line to the wp-config.php file:
define('WP_ALLOW_REPAIR', true);
- This setting turns on database repair.
- From the browser, go to:
http://siteadiniz.com/wp-admin/maint/repair.php
Press the Repair Database button.
- After the process is completed, be sure to delete the line you added.
If the problem persists
-
Consider restoring from backup
-
Check hosting logs
-
Examine the possibility of a traffic explosion or attack
Frequently Asked Questions (FAQ)
1. What causes this error most often? Incorrect database information or stopped MySQL service.
2. What if MySQL is running but the error persists? Database tables may be corrupted.
3. Will this problem occur again? It may occur if there is low RAM and heavy traffic.
4. Does using cache prevent this error? It indirectly reduces the server load.
Result
90% of this error occurs due to MySQL status, incorrect information or corrupt tables. The problem is usually solved when you follow the steps one by one.
👉 You can run WordPress stably with a Cloud Server with powerful resources on the GenixNode platform.

