How to install MySQL on macOS

Step-by-step instructions for installing MySQL on macOS using Homebrew

On macOS, you can easily install MySQL with the following commandHouse wine.


brew install mysql

The above command should take some time, and then print the following:

Now, you can start the MySQL server by running the following command:

brew services start mysql

Now we need to protect the MySQL server. By default, the server does not have a root password, so we need to make sure it is protected.



This process may take some time, but it ensures that you can get the best default settings immediately:

Because we usebrew services start mysqlTo start MySQL, your Mac will restart it when it restarts. You can run:

brew services stop mysql

To prevent this from happening, and immediately stop MySQL.

You can also avoid thisDaemon mode(This is what we call a program that always runs in the background and restarts when the computer restarts) by running:

mysql.server start

This will start MySQL and keep it running until the computer is shut down or running:

mysql.server stop

And it will not restart it on reboot.

It is up to you to decide which one to choose.

Now you can connect to the server using the following command:

mysql -u root -p

You will need to enterrootuser passwordRearYou run this command and when finished, you will see the following screen:

The excellent GUI (graphics) software we can use to interact with the SQLite database is TablePlus.

It comes with a free trial version, which is very suitable for our use, because it is not based on time, but limits the number of concurrent connections you can establish with the database.

Download from I know there are macOS, Windows and Linux versions.

Click "Create a new connection..." and select MySQL in the list:

Then set a name for the connection, then enter "root" and the previously set password:

Click onConnect, You should be connected to MySQL!

Please note that we userootUser, it should only be used for management purposes.

Daily use of the database should be done by ordinary users. We will see it in a separate tutorial.

More database tutorials: