Check and repair a database

repair, optimize, mysql, tables, corruption, wp-cli, phpmyadmin · 0 found this helpful

Tables can become damaged after a crash or full disk. Symptoms include "table is marked as crashed", missing posts, or the database error in Fix "Error establishing a database connection".

Important: Export the database first. See Export a database.

Option 1: phpMyAdmin

  1. Open Account → Hosting → your site → Databases and click Open phpMyAdmin. See Use phpMyAdmin.
  2. Click your database, tick all tables (Check all).
  3. In the With selected menu, choose Check table, then Repair table for any marked bad. Optimize table reclaims space.

Option 2: WP-CLI

cd ~/public_html
wp db check
wp db repair
wp db optimize

Option 3: mysqlcheck

mysqlcheck -u yourusername_shop -p --check yourusername_bakery
mysqlcheck -u yourusername_shop -p --auto-repair --check yourusername_bakery
mysqlcheck -u yourusername_shop -p --optimize yourusername_bakery

What the results mean

Status Meaning
OK Fine
Table is already up to date Fine
Corrupt Repair it
Table doesn't support repair InnoDB tables repair differently. Restore from backup, or export and re-import

InnoDB tables, which WordPress uses today, rarely need repair. If repair doesn't help, restore a recent daily copy from Backups, or ask us to do it. See Back up and restore WordPress.

Keep it healthy

Was this helpful?

Still stuck? Ask us and we'll walk you through it.