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 this guide on how to install Homebrew on MacOS

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

Add new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
6 + 4 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.