How to install MySQL on Mac? Following this article, the work to install MySQL on Mac will get easy to be done.

You can use the brew command to install mysql on Mac. Install mysql through homebrew, the latest version is installed by default. If you want to install other versions, you need to specify the version number. Such as the following code:

brew  install [email protected]
brew install mysql

Very easy?

After installing MySQL on Mac, then how to start MySQL server?

You can redirectly refer how to start MySQL server from the command line on Mac.

Modify configuration file of MySQL

You should to modify the configuration file of MySQL according your requests.


vim /usr/local/etc/my.cnf

# Default Homebrew MySQL server config
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8

collation-server = utf8_unicode_ci
character-set-server = utf8
init-connect ='SET NAMES utf8'
max_allowed_packet = 64M
bind-address =
port = 3306
socket = /tmp/mysql.sock

To start MySQL server on Mac:

brew services start [email protected] 
brew services restart [email protected]  
brew services stop [email protected]     

Using the following command to login the MySQL server.

mysql -u root -p

You will be asked to input the password of mysql, just input the password.

I got a problem when using Homebrew to insall MySQL on Mac, the below content is the approach to solve the problems.

After the installation is complete, I start the mysql using the command:

    mysql.server start

Found no such command error:

    command not found

First, check if it is installed. Re-execute again:

    brew install mysql


    Warning: mysql-5.7.17 already installed, it’s just not linked

Then find the solution online and execute:

    brew link –overwrite mysql


    Linking /usr/local/Cellar/mysql/5.7.17…
    Error: Could not symlink share/man/man8/mysqld.8 /usr/local/share/man/man8 is not writable.

Find the workaround, the following statement is executed successfully:

    sudo chown -R ‘username’ /usr/local

After solving the problem, re-execute:

    brew link –overwrite mysql


Linking /usr/local/Cellar/mysql/5.7.17… 93 symlinks created

do it again:

    mysql.server start

No errors. Indicates that we have started the mysql server and set the administrator password as prompted by brew.