MySQL repair

When you get the following error when repairing database —

error    : Incorrect key file for table './DB/table'; try to repair it
Error    : Incorrect key file for table 'DB_table'; try to repair it

Try the following steps

1. Stop mysql

2. rename the .myi file to something else, like “DISK.BAD”.

  mv /var/lib/mysql/database/*.MYI /root/database_MYI/

3. restart mysql

4. REPAIR TABLE — MySQL will see that the .MYI file is missing and rebuild it. But this time, it will be in a different spot on disk.

  for i in `cat /root/tbs`;do mysql -e "REPAIR TABLE database.$i USE_FRM;";done

when you get the following error


error    : Can't create new tempfile: './DB/table.TMD'
status   : Operation failed

  myisamchk -r -v -f  tables.MYI
Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: