DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

(mysql.info.gz) Crash recovery

Info Catalog (mysql.info.gz) myisamchk memory (mysql.info.gz) Table maintenance (mysql.info.gz) Check
 
 5.7.3.7 Using `myisamchk' for Crash Recovery
 ............................................
 
 If you run `mysqld' with `--skip-external-locking' (which is the
 default on some systems, such as Linux), you can't reliably use
 `myisamchk' to check a table when `mysqld' is using the same table.  If
 you can be sure that no one is accessing the tables through `mysqld'
 while you run `myisamchk', you only have to do `mysqladmin
 flush-tables' before you start checking the tables.  If you can't
 guarantee this, then you must stop `mysqld' while you check the tables.
 If you run `myisamchk' while `mysqld' is updating the tables, you may
 get a warning that a table is corrupt even when it isn't.
 
 If you are not using `--skip-external-locking', you can use `myisamchk'
 to check tables at any time.  While you do this, all clients that try
 to update the table will wait until `myisamchk' is ready before
 continuing.
 
 If you use `myisamchk' to repair or optimize tables, you _must_ always
 ensure that the `mysqld' server is not using the table (this also
 applies if you are using `--skip-external-locking').  If you don't take
 down `mysqld', you should at least do a `mysqladmin flush-tables'
 before you run `myisamchk'.  Your tables _may become corrupted_ if the
 server and `myisamchk' access the tables simultaneously.
 
 This section describes how to check for and deal with data corruption
 in MySQL databases.  If your tables get corrupted frequently you should
 try to find the reason why.   Crashing.
 
 The `MyISAM' table section contains reason for why a table could be
 corrupted.  `MyISAM' table problems MyISAM table problems.
 
 When performing crash recovery, it is important to understand that each
 `MyISAM' table TBL_NAME in a database corresponds to three files in the
 database directory:
 
 *File*         *Purpose*
 `TBL_NAME.frm' Definition (format) file
 `TBL_NAME.MYD' Data file
 `TBL_NAME.MYI' Index file
 
 Each of these three file types is subject to corruption in various
 ways, but problems occur most often in data files and index files.
 
 `myisamchk' works by creating a copy of the `.MYD' data file row by
 row. It ends the repair stage by removing the old `.MYD' file and
 renaming the new file to the original file name.  If you use `--quick',
 `myisamchk' does not create a temporary `.MYD' file, but instead
 assumes that the `.MYD' file is correct and only generates a new index
 file without touching the `.MYD' file. This is safe, because
 `myisamchk' automatically detects whether the `.MYD' file is corrupt
 and aborts the repair if it is.  You can also specify the `--quick'
 option twice to `myisamchk'.  In this case, `myisamchk' does not abort
 on some errors (such as duplicate-key errors) but instead tries to
 resolve them by modifying the `.MYD' file. Normally the use of two
 `--quick' options is useful only if you have too little free disk space
 to perform a normal repair.  In this case, you should at least make a
 backup before running `myisamchk'.
 
Info Catalog (mysql.info.gz) myisamchk memory (mysql.info.gz) Table maintenance (mysql.info.gz) Check
automatically generated byinfo2html