Tuesday 17 December 2019

Repair MySQL database with mysqlcheck

mysqlcheck command can be used to check, repair, optimize or analyzes tables in a MySQL database.
To check a database for errors, run
1
mysqlcheck DB-NAME
If you database need user name and password, specify it with -u USER-NAME -p, for example
1
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.
1
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
1
2
3
REPAIR TABLE tablename;
CHECK TABLE tablename;
OPTIMIZE TABLE tablename;

0 comments:

Post a Comment