Search code examples
mysqlxampp

Unable to start mysql via XAMPP - mysql\db crashed


I have successfully been using XAMPP on my windows 10 PC to run a website that I am working on locally until today.

When I try to start MySQL, it fails. The error logs state:

mysqld.exe: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed
Fatal error: Can't open and lock privilege tables: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed

As I try to fix this, I attempted the following:

mysqlcheck --repair --use-frm --all-databases

but this gives me the following error:

Got error: 2002: Can't connect to MySQL server on 'localhost' (10061) when trying to connect

Which I guess makes sense because the mysql service isnt able to run.

I have also tried running the following from this directory: c:\xampp\mysql\data. Doing this results in an error saying 'db' doesnt exist.:

myisamchk -r db

I noticed that i have a db.MAD file that is rather large 174,616K, so not sure if that is the problem.


Solution

  • I ran into the same problem here is what I did:

    1. Find and open the 'my.ini' file with Notepad. (Mine is at c:\xampp\mysql\bin\my.ini )
    2. Insert 'skip-grant-tables' in the 'my.ini' file on a new line following the label '[mysqld]' and save. You will remove this after the problem is fixed.
    3. Now mySQL you can start XAMPP from the control panel.
    4. Start phpMyAdmin from your browser and select the table 'db' from the database 'mysql' (Select 'mysql' from left panel then check 'db' in right hand panel).
    5. Beneath from the 'With selected' dropdown, run 'analyze' (it should say that it is corrupted). Then select again and run 'repair table'.
    6. Find the 'my.ini' file again and open with Notepad.
    7. Remove 'skip-grant-tables' in the 'my.ini' file and save.
    8. Problem should be fixed and you should be able to start XAMPP normally which will start MySQL normally.