Troubleshooting
Corrupted tables in a MySQL database
Symptoms
An error that mentions a table doesn't prove it is corrupted. Keep the exact code and message: invalid SQL, permissions, lack of disk space, locks or a missing table each need a different procedure.
Before repairing:
- Confirm with a check that the specific table is marked as corrupted.
- Identify its engine in phpMyAdmin.
REPAIR TABLEworks for engines such as MyISAM and, on MariaDB, Aria; it doesn't repair InnoDB. - Keep a backup you can restore. A repair can lock the table or discard damaged data.
Repairing with phpMyAdmin
In phpMyAdmin, select only the confirmed table with a compatible engine and use Repair table. Don't select the whole database as a first step.
Repairing with cPanel
In cPanel > Manage My Databases you may see Repair Database. This action works on the whole database; use it only with a backup available and after confirming that it contains tables this tool can repair.
Repairing over SSH
If you are an advanced user and have SSH access enabled, you can run the repair with the following command:
mysqlcheck -u USUARIO -p BASE TABLA mysqlcheck -u USUARIO -p --repair BASE TABLA
On MariaDB servers, the equivalent command may be mariadb-check. If the table is InnoDB, the server shows errors of its own or there is no valid backup, stop and contact support; don't force a recovery on the shared service.
Validate after the repair
Keep the full output of the check and the repair. Compare counts and application features against a known reference; a table opening again doesn't prove that no damaged records were discarded.
If the error comes back, investigate disk space, logs and server status with support before repeating the repair. Don't add a scheduled repair task as a substitute for diagnosis, and don't run tools against the physical files of a database in use.
The REPAIR TABLE reference details the engines and limits. For InnoDB, recovery has to be planned according to the error and the backup available.
You may also find useful
- Joomla 1.5 and 2.5, compatibility with MySQL 8 Deal with unsupported Joomla's incompatibility with MySQL 8 through isolation, inventory and gradual...
- Old Drupal, conflict with the system table in MySQL 8 Withdraws the unsafe renaming of the system table and points the recovery of Drupal 6 or 7 towards a...
- SQLSTATE 2026 error when installing or updating PrestaShop Diagnose the SSL connection to MySQL that prevents Doctrine from querying the server version, withou...
- Why cPanel and phpMyAdmin show different sizes for a database Explains why cPanel and phpMyAdmin calculate different sizes, how to find the large tables and when...
Something wrong or out of date? Tell us and we will review it.