MySQL Shutdown Unexpectedly in XAMPP? Every Fix (Windows, macOS, Linux)
Fix XAMPP MySQL not starting and Error: MySQL shutdown unexpectedly: port 3306, aria and InnoDB recovery, backup folder, innodb_force_recovery, macOS and Linux.
- Published
- Updated
- Reading time
- 10 min read

On this page 15 sections
- What does "Error: MySQL shutdown unexpectedly" mean?
- Where is the XAMPP MySQL error log?
- How do I fix a port 3306 conflict?
- How do I stop another MySQL service on Windows?
- How do I change the MySQL port in XAMPP?
- How do I fix "aria control file" errors?
- How do I fix corrupted InnoDB or system tables with the backup folder?
- When should I use innodb_force_recovery?
- Why does MySQL fail with permission or antivirus problems?
- How do I fix XAMPP MySQL on macOS and Linux?
- Last resort: move your databases to a fresh XAMPP install
- XAMPP MySQL errors, causes and fixes
- Which fix should I try first?
- How do I prevent MySQL from crashing in XAMPP again?
- Frequently asked questions
Updated 15 October 2026 · By Abhilash Sahoo, Founder, Infyways
Quick answer: "Error: MySQL shutdown unexpectedly" means XAMPP's MariaDB server started and then crashed. Open mysql_error.log (Control Panel → MySQL → Logs) and read the last [ERROR] line:
- "Address already in use" means another program has port 3306. Stop it, or change XAMPP to port 3307.
- "aria control file" errors mean the Aria log is damaged. Back up first, then move
aria_log_controland thearia_log.*files out. - InnoDB or "marked as crashed" errors mean data or system tables are damaged. Restore the system files from
mysql\backupand keep your own databases andibdata1. - No log, or permission errors point to Windows permissions. Run XAMPP as administrator, install it in
C:\xampp, and exclude the folder from your antivirus.
Always copy the mysql\data folder somewhere safe before you change anything.
I installed XAMPP 8.2.12 for Linux (MariaDB 10.4.32) and reproduced the two most common failures, a port conflict and a damaged Aria control file. The terminal images marked "real output" are what the server actually printed. Every command and path below is checked against the official XAMPP FAQ or the MariaDB documentation.
What does "Error: MySQL shutdown unexpectedly" mean?
On Windows, the XAMPP Control Panel prints this exact text when MySQL dies seconds after you click Start:

The message lists every possible cause because the Control Panel can't see the real one. The real reason is in the server's own error log. XAMPP has shipped MariaDB instead of MySQL since versions 5.5.30 and 5.6.14, according to the XAMPP FAQ, so the MariaDB documentation applies. The panel still calls it "MySQL".
Where is the XAMPP MySQL error log?
| Platform | Install folder | Error log | Config file |
|---|---|---|---|
| Windows | C:\xampp | C:\xampp\mysql\data\mysql_error.log | C:\xampp\mysql\bin\my.ini |
| macOS (native installer) | /Applications/XAMPP | /Applications/XAMPP/xamppfiles/var/mysql/<hostname>.err | /Applications/XAMPP/xamppfiles/etc/my.cnf |
| Linux | /opt/lampp | /opt/lampp/var/mysql/<hostname>.err | /opt/lampp/etc/my.cnf |
| macOS XAMPP-VM | Linux virtual machine | Inside the VM, under /opt/lampp/var/mysql/ | Inside the VM, /opt/lampp/etc/my.cnf |
Read the last 20–30 lines. On Linux and macOS, run sudo tail -30 /opt/lampp/var/mysql/*.err (use the matching path on macOS). Lines tagged [Note] are normal. The line that matters is the [ERROR] just before Aborting.

How do I fix a port 3306 conflict?
MariaDB listens on TCP port 3306. If anything else already listens there, the log shows this. It's real output from my test, where another process was holding the port:

Watch for one trap: on Linux and macOS, lampp startmysql still printed "XAMPP: Starting MySQL...ok." even though the server aborted a second later. Don't trust "ok". Check the port and the log.
Find out what owns the port:
:: Windows (Command Prompt as administrator)
netstat -ano | findstr :3306
tasklist /FI "PID eq 1234"
# macOS
sudo lsof -nP -iTCP:3306 -sTCP:LISTEN
# Linux
sudo ss -ltnp | grep 3306

Replace 1234 with the PID from netstat. The usual owners are:
- A standalone MySQL or MariaDB Windows service (often named MySQL80, MySQL57 or MariaDB), installed with MySQL Installer, Workbench, WampServer or Laragon.
- A second XAMPP copy, or an old
mysqld.exeleft running. - Docker containers that publish port 3306.
- On Linux or macOS, a system MySQL. XAMPP's FAQ documents this message for that case: "LAMPP-MySQL is already running. A MySQL daemon is already running."
Skype is often blamed in older guides, but it competed with Apache for ports 80 and 443, not MySQL's 3306.
How do I stop another MySQL service on Windows?
- Press Win + R, type
services.mscand press Enter. - Find MySQL80, MySQL57, MySQL or MariaDB. Right-click it and choose Stop.
- Open Properties and set Startup type to Manual so the service doesn't take the port again at boot.
- Or, from an administrator prompt, run
net stop MySQL80(use the exact service name).
On Linux, stop the system server with sudo systemctl stop mysql or sudo systemctl stop mariadb. On macOS with Homebrew, use brew services stop mysql.
How do I change the MySQL port in XAMPP?
If you need both servers, move XAMPP to 3307. Change port in both the [client] and [mysqld] sections. These are the real lines from XAMPP's Linux my.cnf, and Windows my.ini uses the same keys:

Then reconnect everything else:
- phpMyAdmin: in
phpMyAdmin/config.inc.php, add$cfg['Servers'][$i]['port'] = '3307';next to the existinghostline. Without it, phpMyAdmin shows "mysqli::real_connect(): (HY000/2002)" connection errors. - Your apps: use
127.0.0.1:3307as the database host. That'sDB_HOSTin WordPress'swp-config.php, and$hostplus the port in Joomla'sconfiguration.php. - The command line:
mysql -u root -P 3307 -h 127.0.0.1.
How do I fix "aria control file" errors?
Aria is MariaDB's crash-safe engine for its system tables. If aria_log_control is damaged, for example after a power cut, the whole server refuses to start. I reproduced this by damaging the file on purpose. The fix took one command:

- Stop MySQL and back up the whole data folder.
- Move (don't delete)
aria_log_controland thearia_log.0000000Nfiles out of the data folder. - Start MySQL. MariaDB creates new Aria log files.
- Check your tables with
mysqlcheck -u root --all-databases. On Windows, runC:\xampp\mysql\bin\mysqlcheck.exe.
If individual Aria tables are still damaged, MariaDB's offline tool aria_chk can repair them. MariaDB's docs warn that "aria_chk should not be used when MariaDB is running", so stop the server first. Then, inside the data folder, run aria_chk --check */*.MAI, and aria_chk -r on the tables it flags.
How do I fix corrupted InnoDB or system tables with the backup folder?
On Windows, XAMPP ships a clean copy of the system databases in C:\xampp\mysql\backup. If the log shows "Plugin 'InnoDB' registration as a STORAGE ENGINE failed" or "Table '.\mysql\user' is marked as crashed and last (automatic?) repair failed", rebuild the data folder from it:
- Stop MySQL and close the Control Panel.
- Rename
C:\xampp\mysql\datatodata_old. Keep it: it's your safety net. - Copy
C:\xampp\mysql\backupand name the copydata. - From
data_old, copy your own database folders intodata. Skipmysql,performance_schema,phpmyadminandtest. - Copy
data_old\ibdata1intodataand replace the existing file. Your InnoDB tables depend on it. - Start MySQL. Then run
mysqlcheck -u root --auto-repair --all-databases.
After this, any MySQL user accounts and passwords you created are reset, because they live in the mysql system database. Recreate them in phpMyAdmin.
Is it safe to delete ibdata1 or ib_logfile0?
Don't delete them unless you have a backup. ibdata1 is the InnoDB system tablespace, which holds the data dictionary and undo logs. ib_logfile0 and ib_logfile1 are the redo logs. Deleting them can make every InnoDB table unreadable. If you must experiment, do it on a copy of data_old.
When should I use innodb_force_recovery?
Use it only when the backup-folder method doesn't work and InnoDB still refuses to start. Add one line under [mysqld] in my.ini or my.cnf:
[mysqld]
innodb_force_recovery = 1

MariaDB's documentation says to start at 1 and go up one step at a time. In its words: "With a recovery mode < 4, only corrupted pages should be lost", and "A value of 6 leaves pages in an obsolete state, which might cause more corruption." Once the server starts, export everything straight away with mysqldump -u root --all-databases > all.sql (or use phpMyAdmin Export). Then set the value back to 0 and rebuild from that dump. Don't keep working with recovery mode on.
If a crashed mysql.* table blocks startup, you can repair it the same way. Start the server in a console with mysqld --console --skip-grant-tables, then run mysqlcheck -u root --repair --databases mysql in a second window.
Why does MySQL fail with permission or antivirus problems?
- Install location: the XAMPP installer warns against
C:\Program Files, because User Account Control limits writes there. UseC:\xampp. - Run as administrator: right-click
xampp-control.exeand choose Run as administrator. This is also required to tick the Service box and install MySQL as a Windows service. - Windows Defender or other antivirus: real-time scanning can lock or quarantine
mysqld.exeand data files. Go to Windows Security → Virus & threat protection → Manage settings → Exclusions, and addC:\xampp\mysql. - Linux: XAMPP's FAQ notes that SELinux can block startup with "Cannot restore segment prot after reloc: Permission denied". The data folder must belong to the user set in
my.cnf(user=mysql). - Event Viewer: the Control Panel message itself suggests checking the Windows Event Viewer (Windows Logs → Application) when
mysql_error.logis empty.
How do I fix XAMPP MySQL on macOS and Linux?
macOS native installer. The control app is manager-osx, in /Applications/XAMPP. A leftover mysqld or a Homebrew MySQL is the usual cause:
sudo killall mysqld
sudo /Applications/XAMPP/xamppfiles/xampp startmysql
You can also change the port in manager-osx under Manage Servers → MySQL Database → Configure.
macOS XAMPP-VM. The XAMPP FAQ describes XAMPP-VM as a Linux virtual machine running on your Mac. So the Linux commands below apply inside the VM, not to /Applications/XAMPP.
Linux (/opt/lampp). These are the official commands from the XAMPP Linux FAQ:
sudo /opt/lampp/lampp start # Apache + MySQL
sudo /opt/lampp/lampp stopmysql
sudo /opt/lampp/lampp startmysql
sudo tail -30 /opt/lampp/var/mysql/*.err
Last resort: move your databases to a fresh XAMPP install
If nothing above works, keep your data and replace the server around it:
- Back up
C:\xampp\mysql\data(or/opt/lampp/var/mysql) andhtdocsto another drive. - Dump if you can. If any recovery mode got the server running, export SQL dumps. A dump is the most portable, version-safe backup.
- Uninstall XAMPP, or rename the folder, then install the same XAMPP version fresh. Copying raw data files between different MariaDB versions is risky.
- Start the fresh MySQL once and stop it.
- Import your SQL dumps through phpMyAdmin or
mysql -u root < all.sql. If you have no dumps, copy your database folders plusibdata1,ib_logfile0andib_logfile1from the backup into the new data folder while MySQL is stopped, then start it. - Recreate MySQL users and copy your
htdocsprojects back.
On Linux and macOS, sudo /opt/lampp/lampp backup is documented in the FAQ, but XAMPP labels it a beta feature that "may not work correctly", so don't rely on it alone. Moving a Joomla site this way? Our Joomla transfer guide and Joomla backup guide cover the site side.
XAMPP MySQL errors, causes and fixes

| Log line or symptom | Cause | Fix | Data risk |
|---|---|---|---|
| Can't start server: Bind on TCP/IP port … Address already in use | Port 3306 already taken | Stop the owner, or use port 3307 | None |
| Do you already have another mysqld server running on port: 3306 ? | Second MySQL or MariaDB running | services.msc → stop and set to Manual | None |
| Got error … when trying to use aria control file | Damaged Aria log | Move the aria_log files out | Low |
| Plugin 'InnoDB' registration as a STORAGE ENGINE failed | InnoDB files out of sync | Restore from the backup folder and keep ibdata1 | Medium |
| Table '.\mysql\user' is marked as crashed | Crashed system table | mysqlcheck --repair, or the backup folder | Low (users reset) |
| InnoDB still won't start | Corrupted pages | innodb_force_recovery=1, then dump and rebuild | High |
| Empty log, stops instantly | Permissions, antivirus, Program Files | Run as admin, install in C:\xampp, add an exclusion | None |
| phpMyAdmin HY000/2002 after a port change | phpMyAdmin still uses 3306 | Set the port in config.inc.php | None |
| LAMPP-MySQL is already running | Another mysqld (Linux or macOS) | Stop the other daemon | None |
Which fix should I try first?
| Fix | Time | Touches data? | Try it when |
|---|---|---|---|
| Free port 3306 or change the port | 2 min | No | The log says "Address already in use" |
| Run as admin, add an antivirus exclusion | 2 min | No | The log is empty or shows permission errors |
| Move the aria_log files | 3 min | Logs only | The log shows Aria control file errors |
| Restore from mysql\backup | 10 min | Yes (system DBs) | The log shows InnoDB or crashed-table errors |
| innodb_force_recovery | 15+ min | Read-only rescue | The backup folder method failed |
| Fresh install and re-import | 30+ min | Rebuild | Everything else failed |
How do I prevent MySQL from crashing in XAMPP again?
- Always click Stop on MySQL before you shut down or restart your computer, or before you close the Control Panel. An unclean shutdown while MariaDB is writing is the classic trigger for Aria and InnoDB damage.
- Export your databases regularly. A weekly
mysqldumpor phpMyAdmin export turns any crash into a five-minute restore. - Keep only one MySQL server per port, and set other database services to Manual.
- Install XAMPP in
C:\xampp, not Program Files, and exclude it from antivirus scanning. - Never delete the
mysql\backupfolder. It's your rescue kit. - Remember that XAMPP is for development. The FAQ says it is "not meant for production use". New to local development? See our WordPress development for beginners guide.
Frequently asked questions
Filed under Tutorial
