Repairing & Optimizing Databases
Over time a busy database can pick up minor corruption or slow down as tables grow. cPanel and phpMyAdmin both include tools to check, repair, and optimize your tables so your site keeps running smoothly.
Symptoms of a Problem
A few common signs point to a database that needs attention:
- An error such as
Table 'wp_posts' is marked as crashed and should be repaired. - A page that loads a database-driven section blank or only partly.
- Pages that have become noticeably slow, especially search results or large listings.
- A
MySQL server has gone awaymessage in your application logs.
Repairing from cPanel
cPanel offers the quickest fix for a crashed table:
- Log into cPanel and open MySQL Databases.
- Scroll to Modify Databases.
- Under Repair Database, choose the database and click Repair Database.
- To look for problems without fixing them, use Check Database instead, which reports the status of each table.
Repairing from phpMyAdmin
phpMyAdmin lets you work on individual tables, which is handy when only one is affected:
- Open phpMyAdmin and select the database in the left pane.
- In the table list, tick the box beside the table (or tables) you want to work on.
- From the With selected drop-down at the bottom, choose Check table, Repair table, or Optimize table.
The same actions are available on a single table under its Operations tab. Optimize table reclaims unused space and can speed up a table that has had many rows deleted.
wp_options and wp_postmeta tables. It defragments the data and often trims query times.
"MySQL server has gone away"
This error means the connection to MySQL dropped mid-query. Common causes include:
- A query that ran longer than the server's timeout, often from an unindexed search on a large table.
- A single statement or import larger than the allowed packet size.
- An application holding a connection open while idle for too long.
Retrying the operation usually succeeds. If it keeps happening, look for a slow or oversized query, add missing indexes, or split a large import into smaller pieces as described in Importing & Exporting Databases.
When to Contact Support
Open a support ticket if:
- A repair from cPanel or phpMyAdmin does not clear the crashed-table error.
- You see repeated
MySQL server has gone awayerrors you cannot trace to a specific query. - A table is too large to repair or optimize through the web tools.
- You suspect deeper corruption and want us to restore from a server-side backup.