Pages

Tuesday 8 May 2012

Repair a Mysql database

When we try to repair a MySQL database we can stop the service. If you are using the MyISAM engine I recommend using myisamchk. A basic repair sentence could be like this:
myisamchk -r -q -p -v –sort_buffer_size=2000M /var/lib/mysql/database/table.MYI
The used parameters are the following:
* -r recovery mode
* -q quick recovery, the most common one. If this mode does not work you will have to make some research on your own.
* -p creates the keys to be repared in parallel threads.
* -v verbose mode
* –sort_buffer_size= use this to indicate the size of the buffer to sort the keys. If you do not specify this value, or the value you specify is too small, then you will see something like this myisamchk: error: myisam_sort_buffer_size is too small. To solve this just increment the size of the buffer to be used, if the error always appear then you have a extremely big table.

No comments:

Post a Comment