MySQL
XAMPP
Database Issues
macOS
Troubleshooting

MySQL Database won't start in XAMPP Manager-osx

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

When MySQL fails to start in XAMPP on macOS, the cause is usually a port conflict (another MySQL or MariaDB instance using port 3306), corrupted data files, incorrect file permissions, or a stale PID file. The XAMPP Manager (manager-osx) shows MySQL as "stopped" and clicking Start has no visible effect. This article covers the most common causes and step-by-step fixes, starting from the most likely culprit (port 3306 conflict) to less common issues (data corruption).

Fix 1: Port 3306 Conflict (Most Common)

Another MySQL instance (from Homebrew, a standalone installer, or macOS built-in) may already be using port 3306.

Check What Is Using Port 3306

bash
1# Find the process using port 3306
2sudo lsof -i :3306
3
4# Example output:
5# COMMAND   PID   USER   FD   TYPE  DEVICE  SIZE/OFF NODE NAME
6# mysqld    1234  mysql  22u  IPv4  0x1234  0t0      TCP *:mysql (LISTEN)

Kill the Conflicting Process

bash
1# Kill the process by PID
2sudo kill 1234
3
4# Or force kill
5sudo kill -9 1234
6
7# Verify the port is free
8sudo lsof -i :3306
9# (no output means port is free)

Stop Homebrew MySQL/MariaDB

bash
1# If Homebrew MySQL is running
2brew services stop mysql
3brew services stop mariadb
4
5# Prevent it from starting at login
6brew services stop mysql --no-plist

Change XAMPP MySQL Port

If you need both instances, change XAMPP's MySQL port:

bash
# Edit XAMPP MySQL config
sudo nano /Applications/XAMPP/xamppfiles/etc/my.cnf
ini
[mysqld]
port = 3307

Then restart XAMPP. Connect to MySQL with the new port:

bash
/Applications/XAMPP/xamppfiles/bin/mysql -u root -P 3307

Fix 2: Remove Stale PID File

MySQL uses a PID file to track whether it is running. If MySQL crashes, the PID file may not be cleaned up, preventing a restart.

bash
1# Check for stale PID file
2ls -la /Applications/XAMPP/xamppfiles/var/mysql/*.pid
3
4# Remove it
5sudo rm /Applications/XAMPP/xamppfiles/var/mysql/*.pid
6
7# Try starting MySQL again from XAMPP Manager

Fix 3: Fix File Permissions

XAMPP's MySQL needs correct ownership on its data directory:

bash
1# Fix ownership (XAMPP MySQL runs as daemon/daemon on macOS)
2sudo chown -R mysql:mysql /Applications/XAMPP/xamppfiles/var/mysql/
3
4# Fix permissions
5sudo chmod -R 755 /Applications/XAMPP/xamppfiles/var/mysql/

If you are unsure of the correct user:

bash
# Check XAMPP's MySQL config for the user
grep "^user" /Applications/XAMPP/xamppfiles/etc/my.cnf
# user = mysql

Fix 4: Check Error Logs

The error log reveals exactly why MySQL failed to start:

bash
1# View the MySQL error log
2cat /Applications/XAMPP/xamppfiles/var/mysql/$(hostname).err
3
4# Or tail for the most recent errors
5tail -50 /Applications/XAMPP/xamppfiles/var/mysql/$(hostname).err

Common log messages and their fixes:

Log MessageMeaningFix
Can't start server: Bind on TCP/IP port: Address already in usePort 3306 is takenKill the other process or change port
InnoDB: Unable to lock ./ibdata1Another mysqld holds the lockKill the other MySQL process
Table 'mysql.user' doesn't existSystem tables missingRun mysql_install_db
InnoDB: Corruption in redo logRedo log corruptedDelete ib_logfile0/1, restart

Fix 5: Start MySQL from Terminal

Bypass the XAMPP Manager and start MySQL directly to see error output:

bash
1# Start MySQL manually
2sudo /Applications/XAMPP/xamppfiles/bin/mysqld_safe &
3
4# Or with the XAMPP control script
5sudo /Applications/XAMPP/xamppfiles/xampp startmysql
6
7# Check status
8sudo /Applications/XAMPP/xamppfiles/xampp status

The terminal output shows startup errors that the XAMPP Manager GUI does not display.

Fix 6: Reinstall MySQL Data Directory

If data files are corrupted beyond repair:

bash
1# Backup existing data (if possible)
2sudo cp -r /Applications/XAMPP/xamppfiles/var/mysql /Applications/XAMPP/xamppfiles/var/mysql.bak
3
4# Reinitialize the data directory
5sudo /Applications/XAMPP/xamppfiles/bin/mysql_install_db \
6    --user=mysql \
7    --datadir=/Applications/XAMPP/xamppfiles/var/mysql
8
9# Start MySQL
10sudo /Applications/XAMPP/xamppfiles/xampp startmysql

This creates fresh system tables but erases all existing databases. Import your backups after reinitializing.

Fix 7: InnoDB Recovery

If InnoDB crashes with redo log errors:

bash
1# Stop MySQL
2sudo /Applications/XAMPP/xamppfiles/xampp stopmysql
3
4# Remove InnoDB redo logs (they will be recreated)
5sudo rm /Applications/XAMPP/xamppfiles/var/mysql/ib_logfile0
6sudo rm /Applications/XAMPP/xamppfiles/var/mysql/ib_logfile1
7
8# If still failing, enable recovery mode in my.cnf
9sudo nano /Applications/XAMPP/xamppfiles/etc/my.cnf
ini
[mysqld]
innodb_force_recovery = 1
bash
1# Start MySQL in recovery mode
2sudo /Applications/XAMPP/xamppfiles/xampp startmysql
3
4# Export your databases
5/Applications/XAMPP/xamppfiles/bin/mysqldump --all-databases > backup.sql
6
7# Remove recovery mode from my.cnf, reinitialize, and import

Common Pitfalls

  • Installing MySQL via Homebrew alongside XAMPP: Both try to use port 3306. Either uninstall the Homebrew version (brew uninstall mysql), stop it (brew services stop mysql), or change one instance's port. Running two MySQL servers on the same port is the number one cause of this issue.
  • Not checking error logs before trying fixes: The error log (/Applications/XAMPP/xamppfiles/var/mysql/$(hostname).err) tells you exactly what went wrong. Random troubleshooting without reading the log wastes time and risks making the problem worse.
  • Deleting InnoDB files without backing up first: Removing ibdata1, ib_logfile0, or ib_logfile1 without a backup destroys all InnoDB table data permanently. Always copy the entire mysql data directory before deleting any files.
  • Running XAMPP commands without sudo: XAMPP's MySQL on macOS requires root privileges to start because it binds to port 3306 (a privileged port on some configs) and accesses its data directory. Omitting sudo causes silent permission failures.
  • Ignoring macOS security prompts: macOS may block XAMPP's MySQL binary due to Gatekeeper or quarantine attributes. Check System Preferences > Security & Privacy if MySQL fails to start after a fresh XAMPP install, and allow the binary to run.

Summary

  • Check port 3306 for conflicts first with sudo lsof -i :3306 — this is the most common cause
  • Remove stale PID files from /Applications/XAMPP/xamppfiles/var/mysql/
  • Read the error log (*.err file) for the exact failure reason before trying random fixes
  • Start MySQL from the terminal (mysqld_safe or xampp startmysql) to see error output the GUI hides
  • Fix permissions with sudo chown -R mysql:mysql on the data directory if ownership is wrong

Course illustration
Course illustration

All Rights Reserved.