I wrote a post about setting default character and encoding of MySQL to utf8 on OS X, here. But there is a better way to do this instead of modifying the default my.cnf file directly on Ubuntu.
the last line of my.cnf file
which indicate it will includes any setting files under folder
conf.d. So create a file named
utf8_charset.cnf or whatever name you like, put these lines into the file
Restart mysql, and these setting will be in effect.
The benefit of putting these settings into a seperate file is that these settings will survive when you upgrade your mysql.