
Error Establishing Database Connection
Error Establishing Database Connection: WordPress
Quick Fix
Check wp-config.php for correct DB credentials, ensure MySQL server is running, and clear any corrupted tables. Restart the server and refresh the site.
What it Means
The 'Error Establishing Database Connection' message appears when WordPress cannot connect to its MySQL database. It usually means the credentials in wp-config.php are wrong, the database server is down, or the database file is corrupted.
Possible Causes
- 1Wrong database name, username or password in wp-config.php
- 2MySQL server stopped or unreachable
- 3Corrupted database tables
- 4Insufficient file permissions on wp-config.php
- 5Server resource limits (memory, connections) exceeded
How to Fix
Step-by-Step Solutions
- Verify wp-config.php Credentials
Open wp-config.php and confirm DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST match your hosting settings. A typo will block the connection.
- Check MySQL Service
On the server, run a status check. If it’s stopped, start it. This ensures the database is listening for connections.
systemctl status mysql - Repair Database Tables
Use phpMyAdmin or WP-CLI to run a repair. Corrupted tables often trigger the error.
wp db repair - Restore from Backup
If the database is beyond repair, import a recent backup to restore site data.
wp db import backup.sql
Commands You Can Try
Technical Details
Related Errors
Still stuck?
Pro tips
- Use WP-CLI for faster database checks
- Enable debug mode (define('WP_DEBUG', true);) to see detailed errors
- Set up a staging site to test changes before live
- Monitor MySQL logs for recurring connection issues
Contact your hosting provider or a database administrator if you cannot restart MySQL, if you lack SSH access, or if database corruption persists after repair attempts.
If these solutions didn't help, try searching our database for similar issues.
Contact Support