How do you uninstall MySQL from Mac OS X?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
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:
Verify it is stopped:
Step 2: Remove MySQL Files (DMG Installation)
For MySQL installed via the official macOS DMG installer:
Step 3: Remove User-Level Configuration
Step 4: Remove MySQL from PATH
Check if MySQL added itself to your PATH:
Edit the listed file(s) and remove any line like:
Then reload your shell:
Uninstalling Homebrew MySQL
If MySQL was installed via Homebrew, the process is simpler:
Uninstalling MySQL Installed via MAMP or XAMPP
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:
Remove MySQL User and Group (Optional)
macOS may have created a _mysql user and group during installation:
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:
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.plistis 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
mysqlmay 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
_mysqlorroot. Usesudofor 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 mysqlandps aux | grep mysql

