Table is marked as crashed and should be repaired

If you’re unable to run MySQL through XAMPP Control Panel, first thing to do, is to check error log file. If you find entry saying, that table ./mysql/db (or similar) is marked as crashed and should be repaired then you may find some help in this article.

XAMPP Control Panel 3.1.0 (from XAMPP 1.8.1) reports something like this, after you hit Start in MySQL line:

[mysql] Status change detected: running
[mysql] Status change detected: stopped
[mysql] Error: MySQL shutdown unexpectedly.

First, as always, check c:\XAMPP\mysql\data\mysql_error.log (adjust path according to your operating system and XAMPP installation path). If you find Fatal error: Can't open and lock privilege tables: Table '.mysqldb' is marked as crashed and should be repaired around end of this file, then… one of your tables must be repaired.

You can use myisamchk tool with -r flag for this purpose. Execute:

C:\XAMPP\mysql\bin\myisamchk -r c:\XAMPP\mysql\data\mysql\db.MYI

from your console. Again, adjust paths to your environment.

As a result, you should see something like this:

recovering (with sort) MyISAM-table ‘c:\XAMPP\mysql\data\mysql\db.MYI’
Data records: 4
Fixing index 1
Fixing index 2
Data records: 6

After that all your problems should be gone.

I won’t discuss here, what can cause situation like this, as you’ll find more information about this in following links. Note only, that it can happen in any situation, especially if you don’t expect it, even during normal every-day usage of your development environment.

Some links, if you need more information or if above does not solve your problems:

Happy reparing! :>

Leave a Reply