mysqlcheck - A MySQL Table Maintenance Program

MySQLMySQLi H2 Database

The mysqlcheck client performs table maintenance. It checks, repairs, optimizes, or analyses tables. If the user uses the --databases or --all-databases option to process all tables in one or more databases, invoking mysqlcheck would take a long time. This is true for the MySQL upgrade procedure as well, if it determines that the table checking is required since it processes tables in the same way.

mysqlcheck Usage

  • The command mysqlcheck should be used when the mysqld server is running. This means that the user need not have to stop the server to perform table maintenance. It uses the SQL statements such as CHECK TABLE, REPAIR TABLE, ANALYZE TABLE, and OPTIMIZE TABLE in a convenient way for the user.

  • It helps determine which statements need to be used for the operation that needs to be performed. It then sends the statements to the server so as to be executed.

Invoking mysqlcheck

The three ways to invoke mysqlcheck −

shell> mysqlcheck [options] db_name [tbl_name ...]
shell> mysqlcheck [options] --databases db_name ...
shell> mysqlcheck [options] --all-databases

Default Behaviour

The default behaviour of mysqlcheck is checking tables (--check) that can be changed by renaming the binary. If the user has a tool that repairs tables by default, then a copy of mysqlcheck named mysqlrepair needs to be made. Otherwise, a symbolic link to mysqlcheck named mysqlrepair need to be made. If the user invokes mysqlrepair, it repairs tables.

  • mysqlrepair: It is the default option is –repair.

  • mysqlanalyze: It is the default option is –analyze.

  • mysqloptimize: It is the default option is –optimize.

Published on 10-Mar-2021 17:26:07