The mysqlcheck client tool can check and repair MyISAM tables, and optimize and analyze tables.
In fact, it integrates the functions of check, repair, analyze, and optimize in mysql,
There are three methods to call mysqlcheck:
Shell> mysqlcheck [options] db_name [tables]
Shell> mysqlcheck [options] --- database DB1 [DB2 DB3. ..]
Shell> mysqlcheck [options] -- all -- database
If no table is specified or the --- database or -- all -- database option is used,
Check the entire database.
Option has the following common options:
-C, -- check (checklist );
-R, -- repair (repair table );
-A, -- analyze (analysis table );
-O, -- optimize (optimize table); // among them, the default option is-c (Check table)
Example:
Checklist (check );
Mysqlcheck-u root-c test
Repair table (repair );
Mysqlcheck-u root-r test
Fix a specified database
# Mysqlcheck-A-o-r Database_NAME-p
Check and repair all databases (tables;
# Mysqlcheck-u root-A-0-r-p
Automatically optimize MySQL databases on a daily basis
Crontab-e // Add it to the cron job and automatically execute it at every day.
0 1 *** mysqlcheck-Aao-auto-repair-u your username-p your password>/dev/null 2> & 1