Search the Site


bottom corner

Recovering from MySQL *.MYI corruption

If your application gives you a message similar to "Can't open file: '*.MYI' (errno: 145)", you are likely experiencing a MySQL corruption problem on a particular table. This note details how to recover from this problem fairly easily.

This page is filed under keyword(s): mysql.

Personally, I experienced this with the Bugzilla software issue tracking software. The message I got on the browser screen is as follows.

Software error:

DBD::mysql::db selectrow_array failed: Can't open file: 'logincookies.MYI' (errno: 145) [for Statement "SELECT profiles.userid, profiles.disabledtext FROM logincookies, profiles WHERE logincookies.cookie=? AND logincookies.userid=profiles.userid AND logincookies.userid=? AND (logincookies.ipaddr=? OR logincookies.ipaddr=?)"] at Bugzilla/Auth/ line 69

Bugzilla::Auth::Cookie::authenticate('Bugzilla::Auth::Cookie', 5, 4928) called at Bugzilla/Auth/ line 106

Bugzilla::Auth::CGI::login('Bugzilla::Auth::CGI', 1) called at line 74

Bugzilla::login('Bugzilla') called at C:/bugzilla/buglist.cgi line 81

For help, please send mail to the webmaster (...@......), giving this error message and the time and date of the error.

To resolve the issue, I first stopped the MySQL database.

C:\>net stop mysql
The MySQL service is stopping..
The MySQL service was stopped successfully.

Then, I issued the myisamchk.exe command as below to recover the table that became corrupted; for me, it was the logincookies.MYI file.

C:\>c:\mysql\bin\myisamchk.exe -r logincookies.MYI
- recovering (with sort) MyISAM-table 'logincookies.MYI'
Data records: 158
- Fixing index 1
- Fixing index 2

Once the recovering process was completed, I restarted the MySQL database.

C:\>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.

Once the MySQL restart is completed, the database was functioning properly once again, and my Bugzilla system was running without a hitch. Alternatively, I could have logged in to MySQL and issued the following SQL command to repair the corrupted table.

use bugzilla;
repair table logincookies.MYI;

Did you find this page useful? Please consider browsing other articles or subscribing to the RSS feed to keep up with latest.

This page is filed under keyword(s): mysql.
Author: C. Peter Chen
Last updated: 22 Oct 2008

bottom corner