How to install MySQL on macOS
Beware This post is more than 3 years old, it may be outdated or incorrect! Please check elsewhere for accurate information!
The easiest way to install MySQL on macOS Sierra or newer is to use Homebrew. Homebrew is a package manager for Mac that contains many open source projects packaged in its repositories and they can be installed with a simple command.
Step 1: Install Homebrew
If you don’t have Homebrew already (check by running
brew --version, which should return something like
Homebrew 1.5.4), you can easily install it by running a single command.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It’s going to ask you for your password, and it’s going to download all the necessary dependencies and then install Homebrew.
Be aware that the install will take a few minutes, depending on your Internet speed and whether you have an SSD or not, so please set aside the time to complete the install without interrupting it, as an unexpected interruption can damage the OS on your Mac.
To verify it’s been installed, run the command
brew --version and verify that it outputs, without any errors, the version of Homebrew.
Step 2: Install MySQL
brew install mysql and enter your account password when the software prompts you.
Again, the installation will take a few minutes (usually a minute on an SSD-powered Mac with 80 Mbps Internet).
Step 3: Set MySQL to run at boot
To make sure that MySQL will start on boot, you can add it to the system’s Services list, using another command.
brew service start mysql
It should output something like this:
Successfully started 'mysql'
Step 3: Secure MySQL installation
After the installation is complete, you will have to run another command, to secure the MySQL server with a password:
It will ask you whether to enable a “VALIDATE PASSWORD PLUGIN”, answer No.
Enter your new password, and then enter it again to confirm it.
Answer Yes to everything else.
Congrats! You have installed MySQL. If you need to restart it, you can run
brew services restart mysql .
If you want to administer the database using a GUI, I recommend you use the free, but excellent, app Sequel Pro. (not affiliated)