How to Repair MyISAM Tables MySQL error code 145 = Table was marked as crashed and should be repaired ALTER TABLE  tbl_name  MAX_ROWS= xxx  AVG_ROW_LENGTH= yyy ; 1633 1. Make a backup of the data file before continuing. 2. Use  myisamchk -r  tbl_name  ( -r  means “recovery mode” ). This removes incorrect rows and deleted rows from the data file and reconstructs the index file. 3. If the preceding step fails, use  myisamchk --safe-recover  tbl_name . Safe recovery mode uses an old recovery method that handles a few cases that regular recovery mode does not (but is slower). Stage 2: Easy safe repair Stage 1: Checking your tables Note that error 135 (no more room in record file) and error 136 (no more room in index file) are not errors that can be fixed by a simple repair. In this case, you must use  ALTER TABLE  to increase the  MAX_ROWS and  AVG_ROW_LENGTH  table option values: If you do not know the current table option values, use  SHOW CREATE TABLE . For the other errors, you must repair your tables.  myisamchk  can usually detect and fix most problems that occur. The repair process involves up to three stages, described here. Before you begin, you should change location to the database directory and check the permissions of the table files. On Unix, make sure that they are readable by the user that  mysqld  runs as (and to you, because you need to access the files you are checking). If it turns out you need to modify files, they must also be writable by you. This section is for the cases where a table check fails (such as those described in Section 7.6.2, “How to Check MyISAM Tables for Errors” ), or you want to use the extended features that  myisamchk  provides. The  myisamchk  options used for table maintenance with are described in Section 4.6.4, “myisamchk — MyISAM Table-Maintenance Utility” .  myisamchk  also has variables that you can set to control memory allocation that may improve performance. See Section 4.6.4.6, “myisamchk Memory Usage” . If you are going to repair a table from the command line, you must first stop the  mysqld  server. Note that when you do  mysqladmin shutdown  on a remote server, the  mysqld  server is still available for a while after  mysqladmin  returns, until all statement-processing has stopped and all index changes have been flushed to disk. Run  myisamchk *.MYI  or  myisamchk -e *.MYI  if you have more time. Use the  -s  (silent) option to suppress unnecessary information. If the  mysqld  server is stopped, you should use the  --update-state  option to tell  myisamchk  to mark the table as “checked.” You have to repair only those tables for which  myisamchk  announces an error. For such tables, proceed to Stage 2. If you get unexpected errors when checking (such as  out of memory  errors), or if  myisamchk  crashes, go to Stage 3. First, try  myisamchk -r -q  tbl_name  ( -r -q  means “quick recovery mode” ). This attempts to repair the index file without touching the data file. If the data file contains everything that it should and the delete links point at the correct locations within the data file, this should work, and the table is fixed. Start repairing the next table. Otherwise, use the following procedure: