[MySQL] How to configure my.cnf (Mac + Homebrew Edition)

Tadashi Shigeoka ·  Wed, April 5, 2017

I’ll introduce how to configure my.cnf for MySQL installed with Homebrew on Mac.

MySQL

Find the location of my.cnf file

First, find where my.cnf is loaded from.

$ mysql --help | grep /my.cnf
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf

They are loaded in order from left to right with priority. For custom configuration, it’s recommended to add to /usr/local/etc/my.cnf or ~/.my.cnf.

Copy and create my.cnf

Next, find the location of the MySQL configuration files my*.cnf installed with Homebrew.

$ find /usr/local/Cellar/mysql -name "my*.cnf"
/usr/local/Cellar/mysql/5.7.17/support-files/my-default.cnf

Copy and use my-default.cnf.

$ cp /usr/local/Cellar/mysql/5.7.17/support-files/my-default.cnf /usr/local/etc/my.cnf

After that, just configure my.cnf nicely and you’re done.

Check my.cnf configuration

You can check the my.cnf configuration before and after with the following command.

$ mysql -u root -p
mysql> show variables;

That’s all. Now configure it however you like.

Reference Information

That’s all from the Gemba.