Skip to content

How to uninstall MySQL on a Mac, including the databases Homebrew leaves behind

Stop the server, remove MySQL, then decide about its data folder: on our Mac, 306 MB of databases that brew uninstall does not touch.

6 min read

How do I completely uninstall MySQL on a Mac?

Stop the server, uninstall the program, then remove its data folder only once you have what you need from it. With Homebrew:

brew services stop mysql
brew uninstall mysql
brew cleanup

On our Mac, brew services list showed MySQL 9.5.0 as started, launched at every login by ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist. Stopping it first removes that launch agent and frees port 3306.

Where are my MySQL databases on a Mac?

With Homebrew on Apple silicon, in /opt/homebrew/var/mysql (on Intel, /usr/local/var/mysql). Ours held 306 MB across 33 entries, one folder per database plus the server's own files. brew uninstall leaves this folder in place on purpose, so a reinstall finds your data again.

How do I back up MySQL before uninstalling?

mysqldump --all-databases -u root -p > ~/Desktop/mysql-backup.sql

Run it while the server is still running. Then stop the server, uninstall, and move /opt/homebrew/var/mysql to the Trash only when you are sure.

What else does MySQL leave behind?

WhatWhereSize here
Program/opt/homebrew/Cellar/mysql293 MB
Databases/opt/homebrew/var/mysql306 MB
Settings/opt/homebrew/etc/my.cnf4 KB
Separate client/opt/homebrew/Cellar/mysql-client@8.0150 MB
Command history~/.mysql_history4 KB

The client is its own package, and stays unless you remove it too: brew uninstall mysql-client@8.0. Installed with the official installer instead of Homebrew? Stop it in System Settings, MySQL, then remove /usr/local/mysql* and the MySQL preference pane.

More on what Homebrew keeps: Homebrew packages taking up space. PostgreSQL works the same way: uninstall PostgreSQL.

Common questions

How do I uninstall MySQL installed with Homebrew?

Run brew services stop mysql, then brew uninstall mysql. Remove /opt/homebrew/var/mysql afterwards only if you no longer need the databases.

Does brew uninstall mysql delete my databases?

No. They stay in /opt/homebrew/var/mysql, which was 306 MB on our Mac.

Where is the MySQL data directory on Mac?

With Homebrew on Apple silicon, /opt/homebrew/var/mysql. On Intel Macs, /usr/local/var/mysql.

Read next