DEV Community


Posted on


【XAMPP】How to fix "Error: MySQL shutdown unexpectedly. "

This error happens often in my PC and once it happens your MySQL never starts again.

1.Check the error log.

Click [logs] of MySQL in XAMPP control panel and select [mysql_error.log] to check the error messages.

2.Check if the port "3306" is used.

Click [Netstat] in XAMPP control panel to check "3306" is already used.

3.Restore data in MySQL.

If you can not get any hints to solve the problem, try this step.

1. Find "mysql">"data" folder in XAMPP and copy and paste it somewhere to back it up.

2. Delete files/folders from "mysql">"data" folder.
KEEP the folders with names of DB that you created from "data" folder. Delete everything else.

3. Find "mysql">"backup" folder to copy everything in it.

4. Paste them in "mysql">"data".

5. Copy "ibdata1" file in "data" folder you backed up in step1,and paste it in "mysql">"data" folder.

6. Start MySQL in XAMPP control panel.

4.Set user password for MySQL.

Once the data is restored, your user password for MySQL is reset. You need to set it again.
First, login to MySQL with no password.

mysql -u root
Enter fullscreen mode Exit fullscreen mode

Then, set the user password.

ALTER user 'root'@'localhost' identified by XXXX
Enter fullscreen mode Exit fullscreen mode

then, you can log in MySQL with your password.


Good Luck!!

Top comments (0)