Configuring MySQL for utf8 under homebrew
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.
my.cnf should contain:
[mysqld] collation_server=utf8_general_ci character_set_server=utf8
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
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