Fix XAMPP MySQL Not Starting or Crashing (Windows, macOS, Linux)

MySQL not starting or crashing in XAMPP? Fix common issues like port conflicts, corrupted files, or configuration errors on Windows, macOS, and Linux/Ubuntu with this step-by-step guide.


🧩 Introduction

If you’re unable to start MySQL in XAMPP, or it starts and then shuts down immediately, don’t worry—this is a common problem with clear fixes. It usually happens due to port conflicts, incomplete shutdown, or corrupt data files.


❗ Common Causes

  • Port 3306 is already in use
  • Improper shutdown causing corrupted ibdata1
  • Conflicting services (like MySQL from another software)
  • Misconfigured my.cnf or my.ini
  • Lack of permissions (especially on Linux/macOS)

🖥️ Fix on Windows

✅ Step-by-Step:

  1. Check Which Port Is in Use: netstat -ano | findstr :3306 If another process is using it, identify and stop it.
  2. Stop Conflicting MySQL Services:
    Go to: Services > Look for MySQL or MariaDB Stop it, or uninstall if not needed.
  3. Edit MySQL Port in my.ini:
    XAMPP Control Panel > MySQL > Config > my.ini Change: port=3306 To: port=3307
  4. Delete Corrupted Log/Data Files (only if MySQL was shut improperly):
    • Go to: C:\xampp\mysql\data
    • Backup and then delete:
      • ib_logfile0
      • ib_logfile1
      • ibdata1 (Warning: causes data loss, backup first)
  5. Restart XAMPP as Administrator
    Then try starting MySQL again.

🍏 Fix on macOS

✅ Step-by-Step:

  1. Check Port Usage: sudo lsof -i :3306 If MySQL is running from another app (like MAMP), stop it: sudo pkill mysqld
  2. Change MySQL Port:
    Open: /Applications/XAMPP/xamppfiles/etc/my.cnf Change: port=3306 to: port=3307
  3. Clear Lock Files (optional): sudo rm -f /Applications/XAMPP/xamppfiles/var/mysql/*.err
  4. Fix Permissions: sudo chown -R _mysql:_mysql /Applications/XAMPP/xamppfiles/var/mysql/
  5. Restart Apache and MySQL via XAMPP Manager.

🐧 Fix on Linux/Ubuntu

✅ Step-by-Step:

  1. Kill Conflicting Process: sudo lsof -i :3306 sudo kill -9 [PID]
  2. Change Port in my.cnf: sudo nano /opt/lampp/etc/my.cnf Change: port=3306 to: port=3307
  3. Fix Data Directory Permission Issues: sudo chown -R mysql:mysql /opt/lampp/var/mysql
  4. Remove Lock/Log Files (if crashing): sudo rm /opt/lampp/var/mysql/ib_logfile* sudo rm /opt/lampp/var/mysql/ibdata1 ⚠️ Backup the data folder first.
  5. Restart XAMPP: sudo /opt/lampp/lampp restart

💡 Tips to Avoid Future Issues

  • Always stop MySQL from XAMPP panel before shutting down your system.
  • Regularly backup your databases.
  • Avoid installing multiple MySQL services.

📌 Conclusion

MySQL not starting in XAMPP can feel like a blocker, but it’s often a matter of adjusting port settings or cleaning up after an improper shutdown. Whether you’re on Windows, macOS, or Linux, the above fixes will have your MySQL running again.


💬 Still Not Working?

Paste your my.ini or MySQL error log in the comments, and I’ll help you debug it step by step.


One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *