Remove MySQL database server from macOS or OSX via the command line

To remove an instance of MySQL Database Server from your macOS or OSX installation you need to delete a number of files via the command line, but first ensure that you have database dumps of your databases and that then the database server is not running.

Back Up any needed MySQL databases

Launch the command line and back up the databases:

mysqldump --all-databases > all_databases_export.sql

You may need mysql root access:

mysqldump -uroot -p --all-databases > all_databases_export.sql

Or individually

mysqldump database_name > database_exportname.sql

or with mysql root access:

mysqldump -uroot -p database_name > database_exportname.sql

Stop the MySQL database server

>= MySQL 5.7

sudo launchctl unload -F /Library/LaunchDaemons/

< MySQL 5.7

sudo /usr/local/mysql/support-files/mysql.server stop


Remove MySQL

sudo rm -rf /usr/local/mysq*
sudo rm  /Library/LaunchDaemons/
sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
rm -rf ~/Library/PreferencePanes/MySQL*
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

Optionally check any processes are not running relating to MySQL

ps -ax | grep mysql

If they are, kill them

kill <processIDnumber>

Restart your computer.

That’s it,  MySQL database server  is now totally removed from your system.

Leave all Comment