Installing MySQL on a Mac
This guide walks through how to install MySQL on a Mac via the Homebrew package manager.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

Update

To install Homebrew, open Terminal and run:
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install MySQL using Homebrew:
$ brew install mysql

Install brew services:
$ brew tap homebrew/services


Load and start the MySQL service:
$ brew services start mysql


Expected output: Successfully started mysql (label: homebrew.mxcl.mysql)

Open Terminal and execute the following command to set the root password:
mysqladmin -u root password 'yourpassword'

In this very first guide, we're going to walk through what we need to do to install and like MySQL on a Macintosh system. So the very first thing you're going to do is if you do not have the homebrew package manager installed then I'd recommend going to brew.SH. Now if you go to brew.SH you'll see the homebrew website and the instructions to install it. It's very easy to install. You can simply grab this line of code right here and then paste it into your terminal

./usr/bin/ruby -e "$(curl -fsSLhttps://raw.githubusercontent.com/Homebrew/install/master/install)"

Now if you've never used your terminal before just press command + space and then in the search bar start typing “terminal”. Once you have typed that in hit return and it's going to open it up for you. Now your terminal is your interface for your system. You can run certain commands and have them processed. This is how we'll be able to install MySQL. This is also how we can start the server up and how we can get things going on a system level.

Now if you have not installed homebrew before you can just paste that line of code in from the homebrews Website. If you already have it installed then you can type in brew update just to make sure you have the very latest version of homebrew. Now if you do not have MySQL installed on your system then the way that you install it is the same. That is the same way that you'd install any type of database or library or anything from homebrew which is brew install MySQL.

If you get an error saying MySQL is already installed then don't worry about that, you'll still be able to go through the entire course. If it brings up all of these as binary on all these calls that means you probably didn't have my MySQL installed on your systems. Now how can we test to make sure it's working? The command to check if it is working is is sudo mysql.server start and it will start now and if you run this it's going to ask you for your system password. You should be able to see it saying starting my sequel and that it's successful.

This is how you can tell that it is working now. To stop the server you’re going to do it the same exact way as starting it except you're going to type stop. sudo mysql.server stop. This is going to say shutting down MySQL and that it was successful. Now if you ever run into any issues where the system says ‘it can't connect to mySQL’ it means that you probably just do not have the server running on your system. Go to the terminal and run the exact same command sudo mysql.server start to start it up and you're good to go. From now you can go throughout the entire course and you'll have the database to work from.

Resources