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.

Abhilash SahooFounder & CEO, Infyways
Published
Updated
Reading time
10 min read
Fix MySQL shutdown unexpectedly in XAMPP on Windows, macOS and Linux
On this page 15 sections

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_control and the aria_log.* files out.
  • InnoDB or "marked as crashed" errors mean data or system tables are damaged. Restore the system files from mysql\backup and keep your own databases and ibdata1.
  • 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:

XAMPP Control Panel log: Error: MySQL shutdown unexpectedly

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?

PlatformInstall folderError logConfig file
WindowsC:\xamppC:\xampp\mysql\data\mysql_error.logC:\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-VMLinux virtual machineInside 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.

Decision flow for fixing XAMPP MySQL not starting

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:

Real XAMPP log: Bind on TCP/IP port, Address already in use on port 3306

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
Commands to find the process using port 3306 on Windows, macOS and Linux

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.exe left 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?

  1. Press Win + R, type services.msc and press Enter.
  2. Find MySQL80, MySQL57, MySQL or MariaDB. Right-click it and choose Stop.
  3. Open Properties and set Startup type to Manual so the service doesn't take the port again at boot.
  4. 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:

Changing the XAMPP MySQL port from 3306 to 3307 in my.cnf or my.ini

Then reconnect everything else:

  • phpMyAdmin: in phpMyAdmin/config.inc.php, add $cfg['Servers'][$i]['port'] = '3307'; next to the existing host line. Without it, phpMyAdmin shows "mysqli::real_connect(): (HY000/2002)" connection errors.
  • Your apps: use 127.0.0.1:3307 as the database host. That's DB_HOST in WordPress's wp-config.php, and $host plus the port in Joomla's configuration.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:

Real MariaDB log: aria control file error fixed by moving aria_log files
  1. Stop MySQL and back up the whole data folder.
  2. Move (don't delete) aria_log_control and the aria_log.0000000N files out of the data folder.
  3. Start MySQL. MariaDB creates new Aria log files.
  4. Check your tables with mysqlcheck -u root --all-databases. On Windows, run C:\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:

  1. Stop MySQL and close the Control Panel.
  2. Rename C:\xampp\mysql\data to data_old. Keep it: it's your safety net.
  3. Copy C:\xampp\mysql\backup and name the copy data.
  4. From data_old, copy your own database folders into data. Skip mysql, performance_schema, phpmyadmin and test.
  5. Copy data_old\ibdata1 into data and replace the existing file. Your InnoDB tables depend on it.
  6. 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
innodb_force_recovery modes 0 to 6 explained

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. Use C:\xampp.
  • Run as administrator: right-click xampp-control.exe and 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.exe and data files. Go to Windows Security → Virus & threat protection → Manage settings → Exclusions, and add C:\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.log is 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:

  1. Back up C:\xampp\mysql\data (or /opt/lampp/var/mysql) and htdocs to another drive.
  2. Dump if you can. If any recovery mode got the server running, export SQL dumps. A dump is the most portable, version-safe backup.
  3. Uninstall XAMPP, or rename the folder, then install the same XAMPP version fresh. Copying raw data files between different MariaDB versions is risky.
  4. Start the fresh MySQL once and stop it.
  5. Import your SQL dumps through phpMyAdmin or mysql -u root < all.sql. If you have no dumps, copy your database folders plus ibdata1, ib_logfile0 and ib_logfile1 from the backup into the new data folder while MySQL is stopped, then start it.
  6. Recreate MySQL users and copy your htdocs projects 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

XAMPP MySQL error log lines, causes and fixes
Log line or symptomCauseFixData risk
Can't start server: Bind on TCP/IP port … Address already in usePort 3306 already takenStop the owner, or use port 3307None
Do you already have another mysqld server running on port: 3306 ?Second MySQL or MariaDB runningservices.msc → stop and set to ManualNone
Got error … when trying to use aria control fileDamaged Aria logMove the aria_log files outLow
Plugin 'InnoDB' registration as a STORAGE ENGINE failedInnoDB files out of syncRestore from the backup folder and keep ibdata1Medium
Table '.\mysql\user' is marked as crashedCrashed system tablemysqlcheck --repair, or the backup folderLow (users reset)
InnoDB still won't startCorrupted pagesinnodb_force_recovery=1, then dump and rebuildHigh
Empty log, stops instantlyPermissions, antivirus, Program FilesRun as admin, install in C:\xampp, add an exclusionNone
phpMyAdmin HY000/2002 after a port changephpMyAdmin still uses 3306Set the port in config.inc.phpNone
LAMPP-MySQL is already runningAnother mysqld (Linux or macOS)Stop the other daemonNone

Which fix should I try first?

FixTimeTouches data?Try it when
Free port 3306 or change the port2 minNoThe log says "Address already in use"
Run as admin, add an antivirus exclusion2 minNoThe log is empty or shows permission errors
Move the aria_log files3 minLogs onlyThe log shows Aria control file errors
Restore from mysql\backup10 minYes (system DBs)The log shows InnoDB or crashed-table errors
innodb_force_recovery15+ minRead-only rescueThe backup folder method failed
Fresh install and re-import30+ minRebuildEverything 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 mysqldump or 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\backup folder. 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

The server starts, hits a fatal error and aborts within seconds. The most common causes are port 3306 already being in use and damaged Aria or InnoDB files after an unclean shutdown. The exact reason is the last [ERROR] line in mysql_error.log.

On Windows, it's at C:\xampp\mysql\data\mysql_error.log, or open it from the Logs button. On Linux, it's /opt/lampp/var/mysql/<hostname>.err. On macOS, it's the same file under /Applications/XAMPP/xamppfiles/var/mysql/.

Not if you rename data to data_old first and copy your database folders and ibdata1 back. Only the system databases are replaced, so MySQL user accounts you created are reset.

Yes, on different ports. Set XAMPP to 3307 in both [client] and [mysqld], then update phpMyAdmin's config.inc.php and your apps' database host.

No, not without a full backup. They are InnoDB's system tablespace and redo logs, and deleting them can make every InnoDB table unreadable.

It's an emergency MariaDB setting from 0 to 6 that lets a damaged InnoDB start so you can dump your data. Start at 1, export everything, then set it back to 0. MariaDB warns that higher values can cause more corruption.

MariaDB, since XAMPP 5.5.30 and 5.6.14. The Control Panel still says MySQL, and the commands and tools are the same.

On Linux and macOS, the lampp script prints "ok" when it launches the server, before the server can fail. Check with sudo ss -ltnp | grep 3306, or lsof on macOS, and read the .err log.

On Windows, run C:\xampp\mysql_start.bat. On Linux, run sudo /opt/lampp/lampp startmysql. On macOS, run sudo /Applications/XAMPP/xamppfiles/xampp startmysql.

Only as the last resort, after you back up mysql\data and htdocs. Install the same version and re-import SQL dumps, or copy your database folders back while MySQL is stopped.

Share this article

Filed under Tutorial

Need help with this?

Talk to the Infyways team.

From audits and upgrades to performance and long-term care, we build and maintain the platforms our clients ship on.