开发者

How to repair corrupted table

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 er开发者_C百科ror 140 when trying to recreate indexfile MyISAM-table Sample.MYI is not fixed because of errors".

Now how to repair this table ?


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

How to repair corrupted table

Be 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


Check the status of the corrupted table

check table tablename;

e.g

mysql> check table realtime_clicks_update;
+--------------------------------+-------+----------+----------+
| Table                          | Op    | Msg_type | Msg_text |
+--------------------------------+-------+----------+----------+
| logdata.realtime_clicks_update | check | status   | OK       |
+--------------------------------+-------+----------+----------+

If status is not OK then repair it using following command

mysql> repair table tablename;


Why did you edit the .MYI file? You're not supposed to do that.

Restore from backups then re-apply the changes in the proper fashion.


put back the original Sample.MYI file :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜