Updated: 11 October 2026 · Applies to: MariaDB 10.6 to 11.4 and MySQL 8
mysqlcheck checks, repairs, optimizes and analyzes tables while the database server is running. You can use it on one table, one database or all databases.
Examples
mysqlcheck -c shopdb orders # check one table mysqlcheck -r shopdb orders # repair one table (MyISAM/Aria) mysqlcheck -o shopdb # optimize every table in a database mysqlcheck -a shopdb # update index statistics (analyze) mysqlcheck --all-databases --auto-repair # check all, repair only when needed
Add -u USER -p if you are not using the root account's saved credentials (on cPanel servers, root's ~/.my.cnf is used automatically).
Note: Optimize and repair lock tables while they run. InnoDB tables do not support repair; for those, "optimize" rebuilds the table.