We’ll walk through 3 methods you can use to fix the “Error: MySQL shutdown unexpectedly” error in XAMPP.
Run XAMPP as Administrator
Sometimes XAMPP throws errors when you don’t run it using administrator privileges.
Try to run XAMPP as Administrator and see if the error goes away.
Change MySQL Port
Another root cause may be that MySQL is trying to use the same port as other applications that are already running in the background.
By default, MySQL is using the 3306 port.
To check if other apps are using the same port, open the XAMPP Control Panel, then open Netstat.
If you cannot find any apps that are using the 3306 port, then the issue is somewhere else.
If you did find any apps that are using the 3306 port you have two options:
- Close the other apps and let MySQL run on 3306 port
- Change MySQL’s port
To change MySQL’s port open the XAMPP Control Panel, click on MySQL Config and then open the my.ini
file.
Then you can change the port from here.
But before you do this, make sure that the port you choose will not cause any other conflicts.
Restore the Database Backup
If none of the previous options fixed the error, it means that the databases probably got corrupted.
Check the logs and see what errors are in there.
Navigate to XAMPP Control Panel -> MySQL -> Logs
and open the mysql_error.log
file.
These logs look quite cryptic but I’ve found out that it’s because the MySQL data got corrupted somehow.
Let’s try and fix that.
Copy all the files in xampp/mysql/backup/
 to xampp/mysql/data/
.
Try running the MySQL service once again and see if this fixed the issue.
I hope you found this post helpful!
If you did not manage to fix the error, leave a comment down below and I’ll do my best to help you out.
Let me know what you think about this article in the comments section below.
If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.