What this problem is
WordPress shows: Error establishing a database connection.
Why it happens
- Incorrect DB credentials in
wp-config.php - Database server is down or overloaded
- Corrupted database tables
- Exceeded database user limits
Prerequisites
- Access to
wp-config.php - Hosting panel access (MySQL status, phpMyAdmin)
Diagnosis
- Verify
DB_NAME,DB_USER,DB_PASSWORD,DB_HOST. - Check if the database server is up in the hosting panel.
- Try logging into phpMyAdmin with the same credentials.
Detailed steps
Step 1) Fix credentials in wp-config.php
Update values to match hosting database user and password.
Step 2) Check DB host value
Some hosts require a specific DB_HOST (not always localhost).
Step 3) Repair the database (if tables are corrupted)
Use the dedicated database repair method if needed.
Expected results
- Site loads normally and DB connection is stable
What to do if it fails
- Contact hosting to confirm MySQL service health and whether your account hits limits
Best practices
- Keep backups and monitor DB resources on high-traffic sites