Repairing crashed tables with the MySQL CLI

Use this procedure to repair MySQL tables from the command line:

  1. Log in to the server using SSH.
  2. From the command line, enter this command, replacing [username] with your username and without the brackets:

    mysql -u [username] -p

  3. Enter your password.
  4. Again, without the brackets, enter the command:

    use [databasename];

  5. Enter the command:

    show tables;

  6. Unlike phpMyAdmin, there is no way to repair multiple tables with one command. Instead, you must issue one command per table:
    1. To check a table for errors, enter:

      check table [yourtablename];

    2. To repair a table, enter:

      repair table [yourtablename];

  7. Type quit to return to the command prompt.