Homebrew and MySQL server

So, I got a fresh new macbook last week and decided to use homebrew for my MySQL server installation. I’ve used homebrew for a while and love it, but I had installed MySQL from a package before I knew about homebrew (and maybe before it existed). Anyway, here’s the problem I ran into:

Everything installed just splendidly using brew install mysql, but I have a particularly heavy query on a dev site and the server was responding with “MySQL server has gone away.” No errors were showing up in the .err file (/usr/local/var/mysql) until I used mysql.server start --log-warnings=2. It turned out this was because the max_allowed_packet was too small, so I started the server with mysql.server start --max-allowed-packet=16M and I was golden.

So, I went to put this in my my.cnf file… but there wasn’t one!! I couldn’t find any configurations anywhere! Seemed really weird until I realized that mysql.server was actually running msqld with all the options passed in. So, I tried creating an /etc/my.cnf file and then ~/.my.cnf, but they didn’t work. I kept getting errors like:

ERROR! MySQL server PID file could not be found!
ERROR! The server quit without updating PID file
ERROR! The server quit without updating PID file (/usr/local/var/mysql/cambiodos.local.pid)

I think this may have had something to do with my setting the mysql user to myself. Shit, it seemed to make sense at the time. So, with “ERROR” ringing in my head and my blood pressure rising, I read on the MySQL site somewhere that ~/.my.ini was an alternative to ~/.my.cnf. For some reason it made sense to me to try it and it worked.

I’m guessing this has something to do with the fact that my.cnf is a configuration file and my.ini is just settings? So by using the .ini file I was able to simply override settings, not the absolute configuration, but that’s just a guess. Anyway, I’m happily running mysql with the following ~/.my.ini file:

max_allowed_packet = 16M
log_warnings = 2
default-character-set = utf8


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s