Where is my.cnf on Mac OSX?

On Mountain Lion, I found that the my.cnf file is missing. This is because Mac uses the default MySQL settings and therefore doesn’t require a config file.

If you want to change the default settings, you’ll need to create a my.cnf in /etc/:

You’ll need to sudo into Terminal, and copy one of the default configs from the MySQL folder to the /etc/ folder:

sudo cp /usr/local/mysql/support.files/my-huge.cnf /etc/my.cnf

Then just use Nano or whatever to update the file, then restart MySQL and you should be good to go with your new settings.

Logging MySQL Queries

I often set up mysql query logging when I am diagnosing a problem.

In the my.cnf file, enter (or update the log parameter)


Remember to restart the mysql service:

sudo service mysql restart (ubuntu)
sudo service mysqld restart (centos)

And, ensure that the log file has the correct permissions for mysql to write to it.

After that you can tail the file to see what’s going on:

tail -f /path/to/logfile.log