Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: MySQL shutdown unexpectedly. XAMPP, how to repair a corrupt table

Tags:

mysql

xampp

I have been researching this issue for 2 days now and all the questions and answers do not solve my problem.

Found! in the mysql_error.log after running it several times:

2020-01-06 16:34:11 0 [ERROR] mysqld.exe: Table '.\mysql\user' is marked as crashed and last (automatic?) repair failed

2020-01-06 16:34:11 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table '.\mysql\user' is marked as crashed and last (automatic?) repair failed

So now I see the issue after numerous times trying to start MySQL and reviewing the log, this time I finally see the "user" table is corrupt.

Can anyone advise how to repair this?

like image 520
JRse Avatar asked Sep 05 '25 03:09

JRse


2 Answers

First, from XAMPP control panel, open "Config" [mysql] and add the following line under [mysqld] = innodb_force_recovery = 1

then do the following:

Open shell from control panel and start mysql with this command:

mysqld –-console –-skip-grant-tables –-skip-external-locking
Open another shell from control panel and repair database with this command:
mysqlcheck -r --databases mysql --use-frm
Stop mysql, close shells and restart mysql normally.

IF it doesn't work then change innodb_force_recovery = 2 and repeat process, and again if that doesn't work, change to 3, etc... up to 4

You can find this answer useful

like image 63
Ashish Mishra Avatar answered Sep 08 '25 00:09

Ashish Mishra


I saw this answer in an unclear form here on stackOverflow which helped me, hope this answer helps too

1 - open the directory "c:/xampp/mysql/data" and remove the folder "mysql"

2 - now you will copy the "mysql" folder from "c:/xampp/mysql/backup" and then paste it in the "c:/xampp/mysql/data" directory

Hope this answer helps!

like image 42
Gladson Simões Avatar answered Sep 07 '25 22:09

Gladson Simões