HostOnNet Blog

Repair MySQL database with mysqlcheck

Looking for Linux Server Admin or WordPress Expert? We can help.

mysqlcheck command can be used to check, repair, optimize or analyzes tables in a MySQL database.

To check a database for errors, run

mysqlcheck DB-NAME

If you database need user name and password, specify it with -u USER-NAME -p, for example

mysqlcheck -u USER-NAME -p DB-NAME

This will prompt for MySQL password.

if you want to auto repair any errors found during check, use –auto-repair option.

mysqlcheck --auto-repair DB-NAME

Other useful MySQL commands are mysqlrepair, mysqlanalyze, mysqloptimize. These commands are basically same, just default option changes. For example mysqlcheck use default option –check.

REPAIR TABLE tablename

To repair a table from MYSQL command prompt, you can use

REPAIR TABLE tablename;
CHECK TABLE tablename;


Posted in MySQL

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.