Fixing WordPress Database Connection Errors After Migration
The "Error Establishing a Database Connection" Message
After migrating WordPress to a new host, the most common cause is incorrect credentials in wp-config.php.
Checklist
- Verify
DB_NAME,DB_USER,DB_PASSWORD, andDB_HOSTmatch the new server. - Confirm the database user has
ALL PRIVILEGESon the database. - Check the table prefix (
$table_prefix) matches the migrated tables. - Repair tables if needed by adding to
wp-config.php:
Then visitdefine('WP_ALLOW_REPAIR', true);/wp-admin/maint/repair.php.
Reading the DB Error Log
WordPress database errors are written to debug.log as:
WordPress database error Table 'wp_db.options' doesn't exist for query SELECT... made by require('wp-blog-header.php')
Use the FormatHub WordPress Parser to beautify the failing query and the call path so you can identify which migration step missed a table.