"Error Establishing a Database Connection" means your website is up, but it cannot log in to its own database. In almost every case the cause is simple: the credentials in the site's config file no longer match the real database. Here is the fix order.
Step 1: Read what the site is using
- cPanel → File Manager → public_html → right-click wp-config.php → View (WordPress; other apps have a similar config file).
- Note the four values: DB_NAME, DB_USER, DB_PASSWORD, DB_HOST. The host should be localhost.
Step 2: Compare with the real database
- cPanel → Manage My Databases — check the database name exists exactly as written (prefix included).
- Check the user exists and is connected to that database with privileges — a user that exists but is not attached is the most common hidden cause.
- Test with phpMyAdmin: Databases → phpMyAdmin — if it opens and shows your database's tables, the database itself is healthy and the problem is purely the config credentials.
Step 3: Fix the mismatch
- Password changed at some point? The config file still holds the old one. Either update the config to the current password, or set the database user's password (Manage My Databases) to match the config. One of the two — then reload the site.
- User not attached? In Manage My Databases, use "Add User to Database", grant ALL PRIVILEGES.
- Database name changed by a restore or migration? Update DB_NAME in the config to the real, full name.
✅ Result: The site loads again. If every value matches, phpMyAdmin opens the database, and the error still shows — open a support ticket and tell us the checks you already made; at that point it needs server-side eyes.
⚠ Common mistakes & fixes
- Typing the password with a stray space: passwords in config files are unforgiving. Copy-paste, don't retype.
- Editing the config while the site uses caching: after the fix, reload with a hard refresh or in a private window before concluding it failed.
- Deleting the database "to start fresh": never — the database IS your posts, pages and orders. The error is about connection, not about the data being gone.
Related articles
- How to Create a Database + User (Database Wizard)
- How to Use phpMyAdmin (Import & Export a Database)
- Fix: WordPress White Screen / 500 Error