MYSQLCHECK
The mysqlcheck client can be used to repair, check, optimize OR analyze database tables. To perform these operations, mysqlcheck uses SQL statements REPAIR TABLE, CHECK TABLE, OPTIMIZE TABLE AND ANALYZE TABLE respectively.
AS MyISAM storage engine supports all these four statements, mysqlcheck can be used to perform these operations on MyISAM tables. This is not the case with the other storage Engines, hence may receive an error like “The storage engine for the table doesn’t support check ”
The mysqlcheck performs the check or repair on the tables when the mysqld server is running ie you do not have to stop mysqld server to perform mysqlcheck.
Syntax :
mysqlcheck [options] [db_name [tbl_name, ..] ]
There are numerous options but the regular ones are:
Options :
• –check, -c
Check the tables for errors. This is the default operation.
• –analyze, -a
Analyze the tables.
• –optimize, -o
Optimize the tables.
• –repair, -r
Perform a repair that can fix almost anything except unique keys that are not unique.
mysqlcheck has a special feature compared to other client programs. The default behavior of checking
tables (–check) can be changed by renaming the binary. If you want to have a tool that repairs tables by
default, you should just make a copy of mysqlcheck named mysqlrepair, or make a symbolic link to
mysqlcheck named mysqlrepair. If you invoke mysqlrepair, it repairs tables.
The following names can be used to change mysqlcheck default behavior :
mysqlrepair => The default option is –repair
mysqlanalyze => The default option is –analyze
mysqloptimize => The default option is –optimize
Note : It is best to make a backup of a table before performing a table repair operation