XAMPP: MySQL shutdown unexpectedly

Fix the XAMPP error 'MySQL shutdown unexpectedly' caused by port 3306 conflicts, corrupted MariaDB data files, or insufficient permissions on Windows.

XAMPP displays the "MySQL shutdown unexpectedly" error when MariaDB (MySQL) fails to start due to port conflicts, corrupted data files, or insufficient Windows permissions.

When XAMPP Produces This Error

XAMPP shows "MySQL shutdown unexpectedly" in the XAMPP Control Panel log when MariaDB fails to initialize. The error appears after clicking the Startbutton next to MySQL. The XAMPP Control Panel displays a message similar to:

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

XAMPP produces this MariaDB shutdown error after improper system shutdowns, Windows updates, or when another MySQL/MariaDB instance occupies port 3306.

What Causes "MySQL Shutdown Unexpectedly" in XAMPP

XAMPP MariaDB fails to start for three primary reasons: port conflicts, corrupted data files, and insufficient file permissions.

Port 3306 conflict.XAMPP MariaDB listens on port 3306 by default. If another MySQL or MariaDB installation — such as a standalone MySQL Server or a Docker container — already occupies port 3306, the XAMPP MariaDB process cannot bind to the port and shuts down.

Corrupted MariaDB data files.The ibdata1 file stores the InnoDB data dictionary. The ib_logfile0 and ib_logfile1 files store InnoDB transaction logs. An improper system shutdown or forced XAMPP close can corrupt these files. MariaDB refuses to start when InnoDB detects inconsistent data files.

Insufficient file permissions on Windows.XAMPP requires write access to the C:\xampp\mysql\data\ directory. Running XAMPP without Administrator privileges on Windows prevents MariaDB from writing to its data files.

How to Fix "MySQL Shutdown Unexpectedly" in XAMPP

Fix 1: Run XAMPP as Administrator

  1. Close the XAMPP Control Panel. Navigate to the XAMPP installation directory (default: C:\xampp).

  2. Right-click the xampp-control.exe file. Select Run as administrator.

    XAMPP control panel executable with Run as administrator option

  3. Click Startnext to MySQL in the XAMPP Control Panel. MariaDB starts with full write access to the data directory.

On macOS, right-click the XAMPP application folder and select Get Info. Navigate to Sharing & Permissions. Click the padlock icon and enter the administrator password. Set the permission for all users to Read & Write.

Fix 2: Restore the MariaDB Data Directory from Backup

XAMPP includes a backup copy of the MariaDB data files. Restoring from this backup resolves corruption issues with the InnoDB data dictionary and transaction logs.

  1. Stop MariaDB from the XAMPP Control Panel. Click Stopnext to MySQL.

    XAMPP control panel with MySQL stop button highlighted

  2. Navigate to the XAMPP MariaDB directory at C:\xampp\mysql\. The directory contains a data folder and a backup folder.

    XAMPP MySQL folder structure with data and backup folders

  3. Rename the data folder to data_old. This preserves the corrupted files as a fallback.

  4. Copy the backup folder. Rename the copy to data.

  5. Preserve existing databases from the corrupted data directory. Copy individual database folders (such as wordpress_db or myapp) from data_old into the new data folder. Do not copy the mysql, performance_schema, or phpmyadmin system folders — the backup already contains working copies.

  6. Copy the ibdata1 file from data_old into the new data folder. The ibdata1 file contains the InnoDB tablespace data that custom databases depend on.

  7. Start MariaDB from the XAMPP Control Panel. Click Startnext to MySQL.

Fix 3: Change the MariaDB Port in XAMPP

  1. Open the XAMPP Control Panel. Click Configin the MySQL row and select my.ini.

  2. Search for port=3306 in the my.ini file. Change the value to port=3307.

  3. Save and close my.ini. Restart MariaDB from the XAMPP Control Panel.

  4. Update any application configurations (such as wp-config.php for WordPress) to connect to the new port. Change DB_HOST from localhost to localhost:3307.

How to Verify the Fix

Open the XAMPP Control Panel. The MySQL row displays a green status indicator when MariaDB is running. Click the Adminbutton next to MySQL to open phpMyAdmin in a web browser. phpMyAdmin loads and displays the database list, confirming that MariaDB accepts connections.

Edge Cases and Variations

MariaDB starts but phpMyAdmin shows "Access denied."The MariaDB root password in the restored backup may differ from the current phpMyAdmin configuration. Open C:\xampp\phpMyAdmin\config.inc.php and update the $cfg['Servers'][$i]['password'] value.

MariaDB error log shows "InnoDB: Unable to lock ./ibdata1."Another MariaDB or MySQL process is running and holds a lock on the data files. Check for running mysqld.exe processes in Windows Task Manager and stop them before starting XAMPP MariaDB.

MariaDB fails after restoring the backup folder.The backup folder may not contain the latest InnoDB log files. Delete ib_logfile0 and ib_logfile1 from the data folder. MariaDB regenerates these files on the next startup.

XAMPP MariaDB shutdown after a forced power-off.An unexpected power loss corrupts the InnoDB transaction log. Start MariaDB — InnoDB performs automatic crash recovery. If automatic recovery fails, restore from the backup folder (Fix 2) or delete the InnoDB log files to force regeneration.

XAMPP: Apache shutdown unexpectedly-- caused by port 80 or port 443 conflicts with Skype, IIS, or other Windows services.