Recovering from MySQL *.MYI corruption

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/Cookie.pm line 69

Bugzilla::Auth::Cookie::authenticate(‘Bugzilla::Auth::Cookie’, 5, 4928) called at Bugzilla/Auth/CGI.pm line 106

Bugzilla::Auth::CGI::login(‘Bugzilla::Auth::CGI’, 1) called at Bugzilla.pm 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:mysqlbinmyisamchk.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;

Leave a Reply

Your email address will not be published. Required fields are marked *