Configuring MySQL for utf8 under homebrew

May 8, 2010     

Man, every time I set up mysql it takes me half an hour to google up all the documentation of how to make it just work™ with utf-8 instead of the god forsaken latin1 default. So here it is once and for all.

Server my.cnf should contain:


The location of my.cnf varies depending on how you install it. dev.mysql.com has a nice summary of how my.cnf is looked up.

Since I use homebrew my location is /usr/local/var/mysql/my.cnf. Binary installations differ.

Server config variables are described under Server System Variables

Client configuration goes in ~/.my.cnf:


Client config variables are described under mysql Options

You can check the status of these with SHOW VARIABLES

Finally, as a reminder for homebrew users, if you use the com.mysql.mysqld launchd plist that comes with the homebrew formula then you will want to start and stop the server via launchctl:

launchctl stop com.mysql.mysqld
launchctl start com.mysql.mysqld
Nick Rutherford says…
June 25, 2010 at 1:23AM

Thanks for the write-up.

Between this and the /usr/local/share/mysql/my*.cnf files I turned off network login (sock only), set the unicode defaults (which bit me hard recently), and learned a bit about using launchctl.