Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Fix the XAMPP Error "MySQL Shutdown Unexpectedly"

MySQL in XAMPP starts and stops at once. Read the log, then check the port, the resources, your firewall and the data files.

Databases2 min read10 steps6 screenshots

The error

In the XAMPP Control Panel, MySQL stops with a message such as:

Error: MySQL shutdown unexpectedly.
This may be due to a blocked port, missing dependencies, improper privileges, a crash, or a shutdown by another method.
The MySQL shutdown error

Solution 1: Read the log files

In the Control Panel, click Logs next to MySQL and open mysql_error.log. The last lines tell you what went wrong (a port in use, a damaged table, a permission error...).

The XAMPP Control Panel

Solution 2: Port conflict

Another program may use port 3306.

  1. Open Command Prompt and run:
netstat -ano | findstr 3306
Finding the program that uses port 3306
  1. The last number is the process ID. Find it in Task Manager and close the program, or change the MySQL port.
  2. To change the port, click Config, then my.ini for MySQL, and change port=3306 to another number such as 3307. Change the port in phpMyAdmin\config.inc.php too.
    The my.ini file

Solution 3: Not enough resources

Close programs you do not need. Check the memory and CPU in Task Manager.

Task Manager

Solution 4: Antivirus or firewall

Add XAMPP and mysqld.exe as exceptions in your antivirus and in Windows Defender Firewall.

Windows Defender Firewall

Solution 5: Damaged database files

If the log points to a damaged file, try this:

  1. Stop MySQL.
  2. Back up the folder xampp\mysql\data.
  3. Rename xampp\mysql\data to data_old.
  4. Copy xampp\mysql\backup to a new folder xampp\mysql\data.
  5. Copy your database folders (not mysql, performance_schema and phpmyadmin) from data_old to the new data folder.
  6. Copy the file ibdata1 from data_old to the new data folder.
  7. Start MySQL.

Solution 6: Reinstall XAMPP

If nothing works, back up your htdocs folder and the database folders, remove XAMPP and install it again.

Solution 7: Ask the community

Search the error text in the Apache Friends forum or on Stack Overflow.

Why XAMPP with MySQL

XAMPP gives you Apache, MySQL, PHP and phpMyAdmin in one package, which is good for local development and testing.

Quick recap

  • Start with mysql_error.log.
  • Check the port 3306, the firewall and the data files.
  • Back up before you change or reinstall anything.