Repairing Tables

Tuesday · 22 Oct 02 · 04:30 PM IST | Posted by Karthik | Category: Tech

No I don't mean the tables that you write on, I am referring to MySQL database tables.  A couple of days back, there was some voltage fluctuation at home due to which the computer got shut off several times (besides that, it hanged on a few other occasions as well).  And because of this one of the tables in my database got corrupted.  This has nothing to do with the database I am actually using on the site, it happened to my database at home.  I am writing about it here because it might be helpful to somebody.

If you get strange errors when you try to execute select queries on your tables, then first you have to check them.  In your bin directory wherever you installed MySQL, you will have a program called myisamchk.  First stop your server properly, then run the program on your table like so - myisamchk ../data/databasename/tablename.myi, and if it finds any errors (caused because the server may have been abruptly shut down), you can use myisamchk -r -q whatever.myi for a quick recovery, or if that doesn't work, myisamchk --safe-recover whatever.myi.

This is all thanks to the MySQL User Manual, fortunately I was able to restore my table easily.  And I was thinking of doing something drastic like dropping the table, getting a dump of all my queries from phpMyAdmin, and repeating them all again!

0 comment(s) for this post.
Recent Comments
Recent Posts
Latest Doom Map
Dark Fate 2 — a Doom II map by Karthik Abhiram

Dark Fate 2 is a singleplayer level for Doom II, replacing MAP01.  It's a small-sized hellish level — and there's a walkthrough video as well.

Popular Videos
Other Destinations
Favourite Posts
Some Statistics
  • news posts two · 173
  • news posts one · 301
  • comments · 1168
  • drawings · 77
The Author
Karthik

Karthik Abhiram

27-year old Taurean (birthday 15-May-82), Assistant Manager - HR at Tata Consultancy Services Ltd in Hyderabad, India.  Previously, did Post Graduate Diploma in Management from T A Pai Management Institute (2003-05) and before that, Computer Science Engineering from Sree Nidhi Institute of Science and Technology (1999-2003).

Email: karthik82 -AT- gmail -DOT- com
orkut profile
Facebook profile
YouTube channel
deviantART page
Google Reader Shared Items

Disclaimer: The views expressed on this site are purely my own.

Warning: This site occasionally contains profanity.

Creative Commons License