MySQL Corruption Fun

Sunday, December 16, 2007

So I woke up today to MySQL barfing all over my site:

WordPress database error: [Incorrect key file for table './mydb/wp_posts.MYI'; try to repair it]

Googling the error pushed me toward the myisamchk tool. So I went into MySQL’s data dir on my server as root and tried to run a repair on my files:

myisamchk *.MYI

But I was greeted with this:

myisamchk: unknown variable ’socket=/var/db/mysql/mysql.sock’

I wasn’t feeding it any variables, so I figured it was pulling it from some default config file. First I tried overwriting the value in ~/.my.cnf but that didn’t do anything. After poking around in the MySQL manual I found the --no-defaults option, which should suppress default option file reading for most MySQL clients that consume option variables. Well that worked.

My final command that fixed the corrupt indexes was:

myisamchk --no-defaults --backup --recover *.MYI

Hopefully this saves someone additional time and frustration.

tagged: asides, software
written by Brad Fults

Add your thoughts | Trackback URL

Archived at: http://h3h.net/2007/12/mysql-corruption-fun/

  • Comment Preview
  • Leave a comment

    Comments are posted at the discretion of the site owner. Please try to be respectful, insightful and otherwise useful to society as a whole.

    (X)HTML is allowed. You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <dfn> <em> <kbd> <q cite=""> <samp> <strike> <strong> <sub> <sup> <var>