XAMPP MySQL stops right after you start it
Error: 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.
Fix it fast
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\*.log2Match what you see, then jump to its fix
- 1
netstat 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
The control panel flips back at once, and the log has no clear MySQL error.Antivirus or firewall blocks the database serverFix - 3
The 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
- 1
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=33073Verify
Start MySQL from the control panel; the module turns green and the port is listed.
netstat -ano | findstr :3307Confirmed by apachefriends.org
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.exe2Fix
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 product3Verify
Start MySQL again.
netstat -ano | findstr :3306Confirmed by apachefriends.org
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 /E2Fix
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=13Verify
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.sqlConfirmed by mariadb.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- ShopGoAn e-commerce aggregator with a Python scraping engine behind its catalog, past 10K Google Play downloads.
Related fixes
Databases
Installing the Airflow MySQL provider fails on pkg-config or mysqlclient
Building the mysqlclient wheel fails during the install
The Airflow MySQL provider depends on mysqlclient, which pip compiles against the MySQL C client library.
2 causes, each with a fixDatabases
A query on Aurora MySQL dies with 'table /rdsdbdata/tmp/#sql... is full'
ERROR 1114 (HY000): The table '/rdsdbdata/tmp/#sqlfd_1586_2' is full
In Aurora MySQL 3, internal temporary tables share one pool, and when that pool and the memory-mapped overflow file are used up, a reader instance ends the query with error 1114.
3 causes, each with a fixDatabases
Azure Database for MySQL refuses a connection that does not use SSL
ERROR 3159 (HY000): Connections using insecure transport are prohibited while --require_secure_transport=ON.
Azure Database for MySQL Flexible Server requires encrypted connections by default (require_secure_transport = ON, TLS 1.2).
4 causes, each with a fixDatabases
Compiling a C or C++ program that includes mysql.h fails
undefined reference to `mysql_init'
The compiler only finds mysql.h when the MySQL client development files are installed and their folder is on the include path.
3 causes, each with a fixDatabases
DBeaver fails to resolve Maven dependencies when downloading a database driver
A driver library does not download automatically
DBeaver downloads driver jars from a Maven repository.
3 causes, each with a fixDatabases
DBeaver cannot verify the MySQL server certificate
unable to find valid certification path to requested target
DBeaver's MySQL driver is checking the server certificate and Java does not trust the CA that signed it.
2 causes, each with a fix