MySQL
Mac OS X
uninstall
database management
software removal

How do you uninstall MySQL from Mac OS X?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Uninstalling MySQL from macOS is not a simple drag-to-trash operation. MySQL installs files in multiple locations: binaries in /usr/local/mysql, data in /usr/local/mysql/data, a System Preferences pane, a launch daemon, and user configuration files. Leaving any of these behind can cause conflicts when reinstalling or installing a different version. The process below removes everything.

Step 1: Stop the MySQL Server

Before removing files, stop the running MySQL service:

bash
1# If installed via the official DMG installer
2sudo /usr/local/mysql/support-files/mysql.server stop
3
4# Or via the System Preferences pane
5# Open System Preferences > MySQL > Stop MySQL Server
6
7# If installed via Homebrew
8brew services stop mysql

Verify it is stopped:

bash
ps aux | grep mysql
# Should show no mysqld process (only the grep command itself)

Step 2: Remove MySQL Files (DMG Installation)

For MySQL installed via the official macOS DMG installer:

bash
1# Remove the MySQL installation directory
2sudo rm -rf /usr/local/mysql
3sudo rm -rf /usr/local/mysql*
4
5# Remove the MySQL preferences pane
6sudo rm -rf /Library/PreferencePanes/My*.prefPane
7
8# Remove the startup item and launch daemon
9sudo rm -rf /Library/StartupItems/MySQLCOM
10sudo rm -rf /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist
11sudo rm -rf /Library/LaunchDaemons/com.mysql.mysql.plist
12
13# Remove receipts (macOS package installer records)
14sudo rm -rf /var/db/receipts/com.mysql.*
15
16# Remove configuration files
17sudo rm -rf /etc/my.cnf
18sudo rm -rf /etc/mysql/
19
20# Remove the MySQL user data directory (if separate)
21sudo rm -rf /usr/local/var/mysql

Step 3: Remove User-Level Configuration

bash
1# Remove MySQL shell history and config from your home directory
2rm -rf ~/.mysql_history
3rm -rf ~/.my.cnf
4rm -rf ~/.mysqlsh/
5rm -rf ~/Library/Caches/com.oracle.oss.mysql.mysqld
6rm -rf ~/Library/Preferences/com.oracle.oss.mysql.mysqld.plist

Step 4: Remove MySQL from PATH

Check if MySQL added itself to your PATH:

bash
# Check shell profile files
grep -l mysql ~/.bash_profile ~/.zshrc ~/.bashrc ~/.profile 2>/dev/null

Edit the listed file(s) and remove any line like:

bash
export PATH="/usr/local/mysql/bin:$PATH"

Then reload your shell:

bash
source ~/.zshrc  # or ~/.bash_profile

Uninstalling Homebrew MySQL

If MySQL was installed via Homebrew, the process is simpler:

bash
1# Stop the service
2brew services stop mysql
3
4# Uninstall MySQL
5brew uninstall mysql
6
7# Remove data and configuration
8rm -rf /usr/local/var/mysql
9rm -rf /usr/local/etc/my.cnf
10rm -rf /usr/local/etc/my.cnf.d
11
12# For Apple Silicon Macs (M1/M2/M3)
13rm -rf /opt/homebrew/var/mysql
14rm -rf /opt/homebrew/etc/my.cnf
15
16# Clean up Homebrew cache
17brew cleanup

Uninstalling MySQL Installed via MAMP or XAMPP

bash
1# MAMP
2# Simply delete the MAMP application folder
3rm -rf /Applications/MAMP
4rm -rf /Applications/MAMP\ PRO
5rm -rf ~/Library/Application\ Support/MAMP
6
7# XAMPP
8rm -rf /Applications/XAMPP
9sudo rm -rf /opt/lampp

MAMP and XAMPP bundle MySQL within their own directories, so removing the application removes MySQL as well.

Verify Complete Removal

After removal, verify that MySQL is fully uninstalled:

bash
1# Check for mysql binary
2which mysql
3# Should return nothing or "mysql not found"
4
5# Check for any remaining MySQL processes
6ps aux | grep mysql
7
8# Check for remaining MySQL files
9find / -name "mysql" -type d 2>/dev/null
10
11# Try running mysql
12mysql --version
13# Should return "command not found"

Remove MySQL User and Group (Optional)

macOS may have created a _mysql user and group during installation:

bash
1# Check if the MySQL user exists
2dscl . -read /Users/_mysql 2>/dev/null
3
4# Remove the user (if present)
5sudo dscl . -delete /Users/_mysql
6
7# Remove the group (if present)
8sudo dscl . -delete /Groups/_mysql

Only do this if you are certain no other software depends on these accounts.

Reinstalling After Uninstall

If you plan to reinstall MySQL, a clean removal ensures no leftover configuration causes issues:

bash
1# Via Homebrew (recommended for macOS)
2brew install mysql
3brew services start mysql
4mysql_secure_installation
5
6# Via official DMG
7# Download from https://dev.mysql.com/downloads/mysql/
8# Run the installer package

Common Pitfalls

  • Forgetting /usr/local/mysql/data: This directory contains your databases. If you need to keep your data, back up this directory before removing MySQL. Once deleted, all databases are permanently lost.
  • Leaving the launch daemon: If /Library/LaunchDaemons/com.oracle.oss.mysql.mysqld.plist is left behind, macOS will try to start MySQL on boot and log errors. Always remove it.
  • PATH still pointing to old MySQL: After uninstalling, commands like mysql may still work if your PATH still includes /usr/local/mysql/bin. Remove the PATH entry from your shell profile.
  • Homebrew vs DMG conflict: If you have both a Homebrew and a DMG installation, they will conflict on port 3306. Uninstall one completely before using the other.
  • Permissions errors during removal: Some MySQL directories are owned by _mysql or root. Use sudo for removal commands.

Summary

  • Stop MySQL before removing: sudo /usr/local/mysql/support-files/mysql.server stop
  • Remove the main installation: sudo rm -rf /usr/local/mysql*
  • Remove preference pane, launch daemon, receipts, and config files
  • Clean up user-level files: ~/.my.cnf, ~/.mysql_history, ~/.mysqlsh/
  • Remove MySQL from your shell PATH
  • For Homebrew: brew uninstall mysql && rm -rf /usr/local/var/mysql
  • Verify removal with which mysql and ps aux | grep mysql

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.