X-Combinator

Avatar

making the human scalable

Repairing your MySQL database

Today one of our computer’s /usr partition filled up and caused data corruption in the database. After space was freed up on the partition, we (Moises and I) ran some commands to repair the database. Here is what we did:

  1. cd into your directory where your db files are stored. In our case it was in the /usr…/data/mysql/ folder.
  2. We then run the command:
    myisamchk *.MYI | grep -3 –color corrupted
  3. This should give you some output on the current state of your files and indicate which files are corrupted and needing repair. It also gives you the next command to run on the line that reads:
    Fix it using switch “-r” or “-o”
  4. So that is just what we did
    myisamchk -r file.MYI
  5. Voila, your db should be repaired
del.icio.us:Repairing your MySQL database digg:Repairing your MySQL database reddit:Repairing your MySQL database

One Comment, Comment or Ping

  1. Nate Murray

    Note that mysqlisamchk only works for MyISAM tables. For innodb data recovery check out:

    http://code.google.com/p/innodb-tools/

Reply to “Repairing your MySQL database”