Repair Check and Optimize all Tables
Here is a simple command to auto repair, check and optimize all the tables in all databases running on a MySQL server:
mysqlcheck -u root -p –auto-repair –check –optimize –all-databases
mysqlcheck is available in MySQL 3.23.38 and later.
mysqlcheck uses the SQL statements CHECK TABLE, REPAIR TABLE, ANALYZE TABLE, and OPTIMIZE TABLE in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. The exact operations are determined by the underlying storage engine used.
