Diagnosing a mysql issue
8:42 PM
Tip from Jeff Harr:
For those of you who've never used mysql much, or use it and hope to God nothing horrible happens because you're not sure what to do, here's what I did this morning:
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
</code>
For those of you who've never used mysql much, or use it and hope to God nothing horrible happens because you're not sure what to do, here's what I did this morning:
- I logged into my server and noticed the system load was uncommonly high for that box (a very low 1, actually J ).
- Bugged by the astronomical system load, I cd'd to the data directory, which in this case is: /usr/local/mysql/data. On other builds, it'd be: /var/lib/mysql.
- From here, I tailed the error file, which by default is: <hostname>.err
- I noticed the following error messages:
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
051216 9:44:51 ERROR /usr/local/mysql/bin/mysqld: Can't open file: 'max_adviews.MYI' (errno: 145)
</code>
- If you are like me, you have no idea what errno 145 means. Here's how you find out:
- Find the perror command. On a compiled-on-server build, it'd be most likely in /usr/bin or some other place already in your path. On my installation, an untar-in-some-dir build, it is found in: /usr/local/mysql/bin.
- Then you just: perror 145. In this case, it returned: "MySQL error code 145: Table was marked as crashed and should be repaired"
- So, this means that "max_adviews" has crashed and needs repairing. max_adviews happens to be a "myisam" table (it has a MYI and/or MYD extension), so requires the use of the "myisamchk" command.
- Here's how I repaired it:
- Just like perror, the "myisamchk" is either in a system path or in /usr/local/mysql/bin.
- I don't remember all its flags, so, just like any mysql command, I issued the command with -help.
- help revealed that if I use the -r flag, it will repair the table.
- So: myisamchk -r /usr/local/mysql/data/<database-name>/max_adviews. You don't need the MYI extension
0 comments