EnglishEN

Fix «Error establishing a database connection»

This appears when the database has stopped, the connection details in wp-config.php are wrong, or tables are damaged. Check in this order: repair, connection details, backup restore.

ChemiCloudcPanelDatabasesphpMyAdmin

HostingerhPanelDatabasesphpMyAdmin

Steps

  1. Fix it with phpMyAdmin, or add the line below to wp-config.php.
    define('WP_ALLOW_REPAIR', true);
  2. Open yourdomain.com/wp-admin/maint/repair.php and click Repair Database. When it finishes, delete the line you added.
  3. Check that DB_NAME, DB_USER, and DB_PASSWORD in wp-config.php match your real database. Always check this after moving servers.
  4. If it still doesn't work, restore a backup.

Source

Related posts