Language
      English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flag
      Spanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flag
      Croatian flagDanish flagFinnish flagHindi flagPolish flagRomanian flagSwedish flagNorwegian flag
      Catalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flag
      Slovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flag
      Turkish flagHungarian flagBelarus flagIrish flagIcelandic flagMacedonian flagMalay flagPersian flag
    Tag Cloud
    Sponsors
    Recent Comments
      Archives
      Link with us

      IT Solutions Knowledge Base

      Visitors
      Visits today: 489
      Online visits: 7
Repairing corrupted MySQL databases
Home » Linux, WHM/Cpanel » Repairing corrupted MySQL databases
By Glafkos Charalambous | No CommentsLeave a Comment
Last updated: Sunday, November 30, 2008

Repairing corrupted mysql databases when they get corrupted can happen in many situations. When your databases get corrupted there are plenty of tools available to repair them.

In most cases only the index gets corrupted and not the actual data which is very rare to happen.

In this article we will demostrate myisamchk tool to repair some corrupted mysql databases as well mysqlcheck and repair table command.

Locate mysql databases:

cd /var/lib/mysql

myisamchk Utility (MyISAM Only)
Description: myisamchk can check and repair MyISAM tables

Running the repair command for all database tables:

myisamchk -q -r -f -s  *.MYI

Running the repair command for specific table:

myisamchk -q -r -f -s  table.MYI

Options used:

Change the collation used by the index.
-q, –quick        Faster repair by not modifying the data file. One can give a second ‘-q’ to force myisamchk to modify the original datafile in case of duplicate keys.
NOTE: Tables where the data file is corrupted can’t be fixed with this option.

-r, –recover      Can fix almost anything except unique keys that aren’t unique.

-f, –force         Overwrite old temporary files.

-s, –silent        Only print errors.  One can use two -s to make myisamchk very silent.

Other database repair tools:

REPAIR Table SQL Statement (MyISAM Only)

Usage:

mysql> REPAIR TABLE tablename;

In case the indexing file is missing or is corrupted u can use the USE_FRM option.

mysql> REPAIR TABLE tablename USE_FRM;

mysqlcheck Utility (MyISAM Only)

Usage:

mysqlcheck -r database table -uuser -ppass

  • Digg
  • Facebook
  • Technorati
  • del.icio.us
  • StumbleUpon
  • Sphinn
  • Reddit
  • Google Bookmarks
  • Wikio IT
  • Slashdot
  • co.mments
  • Fark
  • Fleck
  • LinkedIn
  • Ma.gnolia
  • MySpace
  • Propeller
  • Print
  • email

Comments

There are no comments just yet

Leave a Comment

Add your picture!
Join Gravatar and upload your avatar. C'mon, it's free!