Skip to main content

How to Repair a Crashed MySQL Table

You can repair a crashed MySQL or MariaDB table using the phpMyAdmin interface or the command line. This process restores the integrity of a database table that has become corrupted or inaccessible due to a system crash or improper shutdown.

Before you begin

You will need:

  • A Hostek account with access to the database management tools.

  • The specific name of the database and the table that requires repair.

Repairing a table via phpMyAdmin

If you prefer a graphical interface, you can repair a table using phpMyAdmin.

  1. Log in to your hosting control panel and open phpMyAdmin.

  2. Select the database containing the corrupted table from the list on the left.

  3. Click on the specific table name that is showing as "in use" or "crashed."

  4. Click the Operations tab at the top of the page.

  5. Locate the Table maintenance section (or similar section depending on your version).

  6. Click the Repair table link next to the specific table name.

Repairing a table via command line

If you have access to a command-line interface, you can use the mysqlcheck utility to repair tables.

Note: This method is typically used by advanced users or when the table is too large to process efficiently through a web interface.

  1. Connect to your server via SSH.

  2. Run the following command to repair a specific table:

    mysqlcheck -u [username] -p --repair [database_name]/[table_name]

  3. Replace [username] with your database user, [database_name] with the name of your database, and [table_name] with the name of the table.

  4. Enter your password when prompted.

Confirm the result

  • The table will no longer show a "crashed" or "in use" status in phpMyAdmin.

  • You can successfully run a SELECT query on the table to view its data.

  • The table is accessible by your website or application.

If the table remains inaccessible after repair

If the table still shows as crashed or your application cannot connect to it after a repair attempt, the table may have severe structural damage.

  1. Export the data from the table (if possible) using the Export tab in phpMyAdmin.

  2. Drop the corrupted table.

  3. Re-import the data into a newly created table with the correct structure.

  4. If you cannot export the data, contact Hostek support to investigate the specific error.

Limitations

Repairing a table is a local fix for data corruption. If a table crashes frequently, it may indicate an issue with the application's code, a full disk, or a hardware-level issue on the server. If the problem persists after a repair, please contact Hostek support.

Did this answer your question?