|< Day Day Up >|
14.5 Checking and Repairing MyISAM Tables
Brief instructions for using mysqlcheck and myisamchk are given in the following discussion. More detailed information may be found in the "Core Study Guide."
shell> mysqlcheck db_name table_name shell> mysqlcheck --repair db_name table_name
mysqlcheck acts as a command-line interface to the CHECK TABLE and REPAIR TABLE statements. You can issue these statements directly from within the mysql client or from other applications that send statements to the server. By using these statements, you can write your own administrative applications that perform table checking and repair operations.
A recommended table-checking strategy is to run mysqlcheck with no options. If any errors occur, run it again, first with the --repair and --quick options to attempt a quick repair. If that fails, run mysqlcheck with --repair for a normal repair, and then if necessary with --repair and --force.
To check or repair a table with myisamchk, first make sure that the server will not access the table. (One way to do this is to stop the server.) Then change location into the database directory of the database that contains the table and use the following commands:
shell> myisamchk db_name table_name shell> myisamchk --recover db_name table_name
If a repair operation performed with --recover encounters problems that it cannot fix, try using the --safe-recover option. --safe-recover can fix some problems that --recover cannot.
An administrator who is responsible for server operation can instruct the server to check and repair tables automatically. To do this, use the --myisam-recover option. The option value can consist of a comma-separated list of one or more of the following values:
|< Day Day Up >|