How To Repair Corrupted MySQL Tables in Linux

I had this problem for days and can’t find a solution. What I had was .frm, .MYD and .MYI backup files from a previous MySQL installation. My task was to restore these files to the newly reformatted dedicated server. I searched all over the net to find the solution, and here’s what I did (commands are in italics):

  1. Make sure you log in as root.
  2. All the files were in a tarball file: “admin_backup.tar.gz”, so I extracted everything to a directory. tar -xvf admin_backup.tar.gz
  3. Now all the .frm, .MYD and .MYI files are extracted. I placed all the files in the MySQL database folder located at /var/lib/mysql/admin_mike.
  4. I immediately logged into phpMyAdmin and tried to access the tables, but unfortunately it says that “Can’t find file: ‘./admin_mike/sometable.frm’”. What I had to do was check the ownership of the files. ls -la /var/lib/mysql/admin_mike/*
  5. The files should have the ownership like “drwx—— 2 mysql mysql sometable.frm” if not, chown all the backup files. chown mysql:mysql *
  6. I tried to access the tables now in phpMyAdmin, and now they are all accessible!

I thought I’d share this so that others would also fix their own corrupted mysql table. :)

Related Posts with Thumbnails
Share and Enjoy:
  • Print this article!
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Live
  • Netvibes
  • NewsVine
  • Ping.fm
  • Reddit
  • RSS
  • Slashdot
  • StumbleUpon
  • Technorati
  • Twitter
  • Yahoo! Buzz
  • BlinkList

Related posts:

  1. How To Completely Backup your GoDaddy Website Files Godaddy mainly offers domain names for sale, but they are also selling hosting plans including shared hosting, VPS and dedicated...
  2. Search and Replace in MySQL I just went through a domain transfer for one of our websites, and the links in the posts are all...
  3. How to Install/Recompile MCRYPT in PHP (CentOS VPS) I’m starting to develop sites with the Interspire Shopping Cart system, which I think is totally way better than Prestashop....

Your email address goes here:

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>