How to Optimise or Repair a Database in phpMyAdmin Print

  • 0

Over time, database tables can build up wasted space, and occasionally a table gets marked as crashed after a server or app problem. phpMyAdmin can check, optimise and repair tables. You don't need to do this routinely; use it when a table reports an error or a large clean-up has left space unused.

Check, optimise or repair tables

  1. Export a copy of the database first (see import and export a database).
  2. Log in to cPanel and go to Databases › phpMyAdmin.
  3. Click your database in the left-hand list so its tables are shown.
  4. Tick Check all at the bottom of the list, or tick just the tables you want.
  5. From the With selected menu, choose one of:
    • Check table to look for errors without changing anything. Start here.
    • Optimize table to reclaim unused space and tidy the table's storage.
    • Repair table to fix a table that's reported as crashed or corrupt.
  6. phpMyAdmin shows a result for each table. OK means all is well.

MyISAM and InnoDB tables

The Type column shows each table's storage engine, and it affects what you'll see:

  • InnoDB (used by modern WordPress and most current apps) looks after itself and doesn't support Repair table; you'll see a message saying so, which is normal. Optimising an InnoDB table may report "doing recreate + analyze instead", which is also normal and means it worked.
  • MyISAM (common in older apps) is the type that can be marked as crashed, and Repair table is designed for it.

If an InnoDB table reports errors that a check doesn't clear, open a support ticket with the database and table name rather than trying further fixes.

WordPress alternatives

  • WordPress has a built-in repair page. Add define( 'WP_ALLOW_REPAIR', true ); to wp-config.php, visit https://example.co.uk/wp-admin/maint/repair.php, run the repair, then remove the line again (the page works without logging in while it's enabled).
  • A database clean-up plugin can remove old revisions, spam comments and expired data, then optimise the tables for you. Take a backup before running one.

Was this answer helpful?

« Back