Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to repair corrupted table

Tags:

mysql

I have the mysqltable called Sample. I have edited the file /var/lib/mysql/Sample.MYI with some values. Now check TABLE Sample query shows as

Incorrect key file for table 'Sample'; try to repair it

To repair this, i have tried using the following command myisamchk -r Sample.MYI. but the result is "myisamchk:

error: Got error 140 when trying to recreate indexfile MyISAM-table Sample.MYI is not fixed because of errors".

Now how to repair this table ?

like image 433
ssbecse Avatar asked May 30 '11 13:05

ssbecse


1 Answers

Just in case you don't have backup, don't have the original file and cannot redownload it, here are some links that might help you:

http://www.felipecruz.com/repair-mysql-database.php
http://dev.mysql.com/doc/refman/5.0/en/myisam-repair.html (see also links at the bottom of this page)
http://forums.mysql.com/read.php?21,362974,362974

The following command will recreate .myi files from scratch:

REPAIR TABLE tablename USE_FRM

enter image description hereBe careful with this though, this page: http://dev.mysql.com/doc/refman/5.5/en/repair-table.html says:

Use the USE_FRM option only if you cannot use regular REPAIR modes! Telling the server to ignore the .MYI file makes important table metadata stored in the .MYI unavailable to the repair process, which can have deleterious consequences:[.....]

And finally how to redo this in different ways:

http://www-users.cs.york.ac.uk/susan/joke/foot.htm

like image 113
Johan Avatar answered Oct 04 '22 20:10

Johan