Case 12 · WordPress troubleshooting

WordPress Database Connection Error? Getting Your Website Back Online

Short answer

'Error establishing a database connection' means WordPress cannot reach its MySQL or MariaDB database. The usual causes are wrong login details in wp-config.php, a database server that is down or overloaded, or corrupted tables. Checking the credentials and the database server first, then repairing tables, brings most sites back.

The challenge

This is a typical scenario based on the kinds of challenges WordPress site owners bring to us. Names and details are illustrative.

A school updates its hosting control-panel passwords as part of an IT security review. That evening, parents trying to check admission notices see a plain white page with a single line: “Error establishing a database connection.” The website, the admission form and the notices are all unreachable.

Nothing in the database has been damaged. The database user’s password was changed in the hosting panel, but the copy stored in the website’s wp-config.php file was not updated, so WordPress is still knocking with the old key.

Warning signs to look for

  • Every page shows only the text 'Error establishing a database connection'.
  • The admin area shows 'One or more database tables are unavailable'.
  • The error appears after changing hosting, passwords or the database name.
  • The site goes down at busy times and returns on its own later.

Common causes

Incorrect database credentials
The database name, user, password or host in wp-config.php no longer match, often after a migration or a password change in the hosting panel.
Database server down or overloaded
On shared hosting, the MySQL server can be restarted, overloaded by other sites or limited by connection caps.
Corrupted database tables
A crash, a full disk or an interrupted update leaves tables damaged, so WordPress cannot read them.
Hosting limits reached
Too many simultaneous connections from traffic spikes, bots or heavy plugins exceed the plan's limits.

What it costs your business

The entire website, including every page, form and the admin area, is unavailable until the database is reachable again. For stores and membership sites, a damaged database can also mean lost orders or user data if there is no recent backup.

Our approach

  1. 1

    Check credentials in wp-config.php

    We verify the database name, user, password and host against the hosting control panel and test the connection directly.

  2. 2

    Check the database server

    We confirm whether MySQL or MariaDB is running and whether connection or resource limits are being hit, and work with the host if the server itself is at fault.

  3. 3

    Repair damaged tables

    If tables are corrupted, we back up what exists, then run a repair through the hosting tools or WordPress's built-in repair mode, and disable repair mode afterwards.

  4. 4

    Restore if needed

    If tables cannot be repaired, we restore the database from the most recent clean backup and re-apply any recoverable recent changes, such as orders recorded in emails.

  5. 5

    Reduce future load

    We clean up bloated tables, limit bot traffic and add caching so the database is not overloaded again.

Services delivered

WordPress Maintenance

  • Frequent database backups mean a restore loses as little as possible.
  • Uptime monitoring alerts us as soon as the site stops responding.
  • Regular database clean-ups keep tables small and healthy.
  • We liaise with your hosting provider on server-side issues.

The outcome

Updating the credentials brings the site back within minutes. The case still leads to useful changes: a note in the school's IT checklist that website credentials must be updated together, a check that backups are current, and monitoring so a future outage is spotted that same evening rather than by parents.

How to prevent it happening again

  • Keep regular database backups, more often for stores and busy sites.
  • Update wp-config.php immediately when database passwords change.
  • Keep the database clean: remove spam comments, old revisions and expired transients.
  • Use caching and bot protection to reduce unnecessary database queries.
  • Move to better hosting if connection limits are being reached regularly.

FAQ

Frequently asked questions

Is my website data lost when this error appears?

Usually not. Most of the time the data is intact and WordPress simply cannot connect. Data loss is only a risk when tables are corrupted and there is no recent backup.

What is WP_ALLOW_REPAIR?

It is a setting added to wp-config.php that enables WordPress's database repair page. It should only be switched on while repairing, because the page does not require a login, and removed immediately afterwards.

Why does the error come and go?

An intermittent database error usually means the database server is reaching its limits at busy times. Caching, blocking bad bots and better hosting typically solve it.

Want this handled before it happens?

Our WordPress maintenance plans cover updates, backups, security monitoring and fixes, so problems like this are caught early.