We stand with Ukraine to help keep people safe. Join us
HomeHow-ToHow to Uninstall MySQL on a Mac
Default main image of How to Uninstall MySQL on a Mac

How to Uninstall MySQL on a Mac

If you are thinking about completely uninstalling MySQL, it is not as straightforward as it sounds. This tutorial will provide you with step by step instructions on how to perform a clean uninstall of MySQL on your MacBook.

Step 1: Make a backup of your databases

If you want to retain your databases when MySQL is deleted, make sure that you make a backup of them.

mysqldump​ command creates a text file dump of your databases. If you decide to recreate them at a later stage, it is easy to do so when you have a backup with the .sql extension.

To create a backup,

Hit command + space to bring up the Spotlight Search.

Search for Terminal and click on it.

how to uninstall MySQL on Mac

Type the command below to navigate to the file containing the binaries of MySQL.

cd /usr/local/mysql/bin

Type the command below, and it will create a file called ​all_databases.sql​.

./mysqldump --all-databases > all_databases.sql

This file will contain queries that could be used to restore your databases, which will come useful should you require to build them back.

Now that you have made a backup let's go ahead and perform a clean uninstall of MySQL.

Step 2: Stop the MySQL Server

This step could be easily done from the System Preferences panel. However, you could perform the same step from the Terminal itself. Let's look at both ways in detail.

Stopping the MySQL Server from the System Preferences panel

Navigate to System Preferences.

Towards the bottom of the panel, you will find the MySQL service. Click on it and navigate to the MySQL panel.

Click on Stop MySQL Server.

uninstall MySQL Mac

Stopping the MySQL server from the Terminal

For those of you who used Homebrew to install MySQL, please enter the command below to stop the MySQL server.

brew services stop mysql

To check if the command worked, you can list the services by running the following command.

brew services list

Check if the status of MySQL has changed to 'stopped.'

If you installed MySQL by other means, please follow these steps.

Type the command below to navigate to the file containing the binaries of MySQL.

cd /usr/local/mysql/bin

Then run the following command to stop the MySQL server.

If you have set up your root account without a password,

./mysqladmin -u root shutdown

If you have set up your root account with a password,

./mysqladmin -u root -p password shutdown

(please replace password with your root password when entering the command)

To ensure the command has worked, you can navigate to the MySQL pane from the System preferences panel and see if the button has changed from Stop MySQL Server to Start MySQL Server.

Step 3: Remove all elements of MySQL

These steps are essential when uninstalling MySQL as you will be unable to install an older version of MySQL if these elements remain in your macOS environment.

To remove the MySQL folder and all of its contents,

sudo rm -rf /usr/local/mysql
sudo rm -rf /usr/local/mysql*

If prompted, please enter the password.

remove MySQL from Mac

Executing both the commands will ensure that you will delete the MySQL folder and any symbolic link pointing to that folder.

To remove Startup Items and the Preferences panes,

sudo rm -rf /Library/StartupItems/MySQLCOM
sudo rm -rf /Library/PreferencePanes/My*
delete MySQL on Mac

The Receipts folder contains elements of MySQL that are created while the MySQL server is running. To delete this folder,

sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*
how to remove MySQL from Mac

These commands will ensure that your MacOS environment is completely free from any elements created by MySQL while installing and running.

Please note that depending on how you have run MySQL, one or more files will not be available in your system. If any of the commands are giving you a, "no matches found" error, please ignore it.

By following the steps, you have successfully uninstalled MySQL. Now you can install a different version of MySQL and restore the databases using the backup you created.