Using MySQL On Mac – Install MySQL Mac

Table of Contents

The install MySQL Mac process should be a straightforward one but it does not have to have a step-by-step guide. In this post, we will look at the install MySQL mac process and also look at the uninstall MySQL Mac process.

Installing MySQL On A Mac

Before you do anything else, identify the version of MacOS you’re running. If you’re not sure, click the icon of an apple at the top right of your screen and then click on ‘About’.

Once you know the version you are running, you are ready to look for the version of MySQL you want to install on your computer. In this post, we will look at several ways of downloading MySQL and installing in on your Mac.

MySQL is a free, open-source database management system that has a community version (the free one) and this is what you will typically work with unless you are looking for an Enterprise solution (the paid one).

Downloading MySQL Server

To install MySQL Mac, you need to first download the community server from the MySQL website. Once you get to the site, it automatically detects your operating system, but it does not always work. The installer options available for download include .dmg, .tar, or .tar.gz.

We recommend you download the .dmg file as it is easier to install than the rest of the files available. Once you land on the downloads page, you will see prompts to either login or sign up – you don’t have to. Below the login and sign up option is a link to automatically start your download – click on it ‘No thanks just start my download’.

Once the download is complete, double click on it and follow the prompts to start the installation. Depending on what you are using for terminal – ZSH or bash (default) – you should add your MySQL path as ~/.zshrc or ~/.bash_profile respectively. To use the ‘mysql’ command from the command line, you also need to alter the download to your path as follows:

Export PATH=$PATH:/usr/local/mysql/bin

After adding the download to your path, test it out to ensure it is working by looking up something like the version you are running:

$ mysql --version

With the ability to access MySQL from the Terminal, the only thing left is connecting to the database and starting your MySQL server. To start using the server, log in as the root use ‘root@localhost’. For the first login, you need to use the initial password you got during the installation process.

~ mysql -uroot -p

When you enter that command it will prompt you to enter the password and you’ll finally be logged onto your Server.

However, the initial password from the installation is often jargon and one you will be hard-pressed to remember every time you need to log in as the root user. So the next process before you can relax is changing the root password to the one you can easily remember.

If you are running OSX, the command to change the root password is:

Mysql > SET PASSWORD FOR 'root'@localhost' = PASSWORD('root')

You can replace the password we have as the sample password above ‘root’ to whichever password you prefer and can easily remember.

Uninstalling MySQL From Mac

There is a chance that at some point you will need to uninstall MySQL from your Mac. You might not need it anymore, or you might be looking to do away with an old version and start afresh with a new version. For this, you need to understand the complete uninstall MySQL Mac.

Simply removing MySQL from the system preferences window is barely enough to clean all traces of the program from your computer. You also need to get rid of all MySQL service files and a simple purge from preferences doesn’t cut it.

Below, we look at how you can completely purge a copy and any traces of MySQL on your Mac.

If you think you might need your databases afterward, you need to backup your database before you uninstall MySQL.

From the terminal, use the mysqldump command to execute a backup. Check for any running MySQL processes and stop all running processes.

From HomeBrew, run the following commands:

brew remove mysql
brew cleanup

To remove existing MySQL files, run the following commands:

 Sudo rm /usr/local/mysql
Sudo rm -rf /usr/local/var/mysql
Sudo rm -rf/usr/local/mysql*
Sudo rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Sudo rm -rf /Library/StartupItems/MySQLCOM
Sudo rm -rf /Library/PreferencesPanes/My*

And

Subl /etc/hostconfig'
# remove the line MYSQLCOM=-YES-

The last step before restarting your computer is removing former MySQL preferences:

 rm -rf ~/Library/PreferencePanes/My*    
sudo rm -rf /Library/Receipts/mysql*
sudo rm -rf /Library/Receipts/MySQL*
sudo rm -rf /private/var/db/receipts/*mysql*

Once all this is done, a computer restart will ensure everything has been purged for good. Hopefully, it is now easier for you to install and uninstall MySQL on your Mac.

Below, we look at how you can completely purge a copy and any traces of MySQL on your Mac.

If you think you might need your databases afterward, you need to backup your database before you uninstall MySQL.

From the terminal, use the mysldump command to execute a backup. Check for any running MySQL processes and stop all running processes.

Once all this is done, a computer restart will ensure everything has been purged for good. Hopefully, it is now easier for you to install and uninstall MySQL on your Mac.

Ready to secure your backups today?

Try for free
14 Day Free Trial • Cancel Anytime • No Credit Card Required