Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Databases and Redis

XAMPP MySQL stops right after you start it

ErrorError: MySQL shutdown unexpectedly.

Short answer

The XAMPP message is generic. The cause is in the MySQL error log (open it from the Logs button of the XAMPP Control Panel). The documented ones are another server on port 3306, antivirus or firewall blocking, and corrupted InnoDB files. Fix the port first, because it is the cheapest to check and change.

  • Applies to XAMPP 8.2 for Windows, MariaDB 10.4 to 10.6
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Open a command prompt as administrator and see who owns port 3306. Then open the MySQL error log: the Logs button next to MySQL in the XAMPP Control Panel, or the log files in xampp\mysql\data.

    netstat -ano | findstr :3306
    dir C:\xampp\mysql\data\*.err C:\xampp\mysql\data\*.log
  2. 2Match what you see, then jump to its fix

    1. 1netstat shows a LISTENING entry on 3306 before you start XAMPP, or the log says the port is in use.Another MySQL server already uses port 3306Fix
    2. 2The control panel flips back at once, and the log has no clear MySQL error.Antivirus or firewall blocks the database serverFix
    3. 3The MySQL error log contains InnoDB errors, usually about the redo log or a tablespace, not a port message.InnoDB files are damaged after a crash or power lossFix

What does the error look like?

  • Error: MySQL shutdown unexpectedly.

Cause 1 of 3

Another MySQL server already uses port 3306

1Check

Two servers cannot share a port. A Windows MySQL service or a second install is the usual owner. Match the PID from netstat to a program.

netstat -ano | findstr :3306
tasklist /FI "PID eq 1234"

2Fix

Stop or remove the other server, or change the port XAMPP's MySQL uses in my.ini (xampp\mysql\bin\my.ini) and use the same port in your app and phpMyAdmin config.

; xampp\mysql\bin\my.ini, both sections
[client]
port=3307
[mysqld]
port=3307

3Verify

Start MySQL from the control panel; the module turns green and the port is listed.

netstat -ano | findstr :3307

Confirmed by apachefriends.org

Did this fix it?

Cause 2 of 3

Antivirus or firewall blocks the database server

1Check

The XAMPP FAQ lists antivirus software as a blocker of the web and database servers. Look at your security product's block log for mysqld.exe.

# Open your antivirus or firewall log and look for mysqld.exe

2Fix

Add mysqld.exe and the XAMPP folder as exceptions, or add the firewall rule for the server.

# Add exception for C:\xampp\mysql\bin\mysqld.exe in your security product

3Verify

Start MySQL again.

netstat -ano | findstr :3306

Confirmed by apachefriends.org

Did this fix it?

Cause 3 of 3

InnoDB files are damaged after a crash or power loss

1Check

Back up xampp\mysql\data first. Copy the whole folder somewhere safe before any recovery step.

robocopy C:\xampp\mysql\data C:\xampp\mysql\data_backup /E

2Fix

Start with innodb_force_recovery=1 and raise it one step at a time only if needed. Recovery mode repairs nothing: when the server starts, dump the databases, then recreate the data directory and import. Remove the setting afterwards.

; my.ini, [mysqld]
innodb_force_recovery=1

3Verify

Dump the databases while the server is up, then check your tables.

C:\xampp\mysql\bin\mysqldump.exe -u root --all-databases > C:\backup\all.sql

Confirmed by mariadb.com

Did this fix it?

How do I stop it coming back?

  • Stop MySQL from the control panel before shutting down Windows.
  • Keep only one MySQL or MariaDB server running on the machine.
  • Take a dump of the databases regularly, not only a copy of the data folder.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.