How to install MySQL on macOS with Homebrew

How to install MySQL on macOS with Homebrew

This tutorial will guide you to install MySQL on your macOS with Homebrew.

Homebrew is a package manager to provide a command-line tool to manage your utilities and applications.

NOTE: Make sure you have homebrew installed. If not then simply follow the guide here https://brew.sh/

 

Installation process:

1. Now simply run the below command in your terminal

$ brew install mysql

2. Start the MySQL service

$ brew services start mysql

3. Set root MySQL password

$ mysqladmin -u root password 'secretpassword'

4. Access MySQL on mac

$ mysql -u root -p

Command will ask the password you just set in the previous step.

 

Things to remember

Stop MySQL service on Mac start

If you don't want MySQL service to start every time you start your mac then run the below command

$ brew services stop mysql

This will stop the MySQL service from running in the background.

Start MySQL service

You can always run the below command to start the MySQL server on mac and it will not start on the next computer restart

$ mysql.server start

Stop MySQL service

If you want to immediately stop the MySQL service then run the below command

$ mysql.server stop

GUI clients to access database

And you can also access your database with mac MySQL client to make your life easy. Here are a couple of suggestions:

 

Cover Photo by Devin Avery on Unsplash