Best easy tutorial to recover mysql database errors using mysqlcheck and myisamchk
Written by anil on Saturday, June 23rd, 2007 in mysql, Linux, cPanel/WHM.
mysqlcheck and myisamchk are used to check and repair tables (MYISAM Tables). They can help you keep your tables free from errors. If any errors occurred to MySQL database due to a server crash or by an unexpected MySQL service issue, those commands can be used to recover or repair your valuable MySQL databases. So what is the difference between mysqlcheck and myisamchk . . .
mysqlcheck is a client program that communicate with the MySQL server over a network connection. To use mysqlcheck the MySQL server should be online. This also means that you can use mysqlcheck to repair a remote database. myisamcheck isn't a client program. It is a utility program that works directly on the files that represent MyISAM tables (.MYI files, inside MySQL database directory). You must need read write privileges on these files to use myisamchk.
When using myisamcheck on tables inside a database, the tables must not be accessed during the check. The safest method is to bring the server down during a myisamchk. Otherwise it will not give the results you are expecting.
Now the theory part is over … ;). Lets do some MySQL database repairing . . .
BEFORE PERFORMING OPERATIONS SPECIFIED IN THIS TUTORIAL PLEASE TAKE A BACKUP OF YOUR DATABASE
First mysqlcheck . . . By default if we doesn't provide any options mysqlcheck takes the first argument as the database name and check all the tables inside it. Example :-