Most info on the Net says to do the below. So I wanted to combine those into just 1 statement instead of 2.
init-connect='SET NAMES utf8' init_connect='SET CHARACTER SET=utf-8'
Add to your /etc/my.cnf
[mysqld] init_connect='SET collation_connection = utf8_general_ci,NAMES utf8' character-set-server = utf8 collation-server = utf8_general_ci
You can change the default server character set and collation with the --character-set-server and --collation-server options when you start the server. The collation must be a legal collation for the default character set.
init_connect='SET collation_connection = utf8_general_ci,NAMES utf8' collation_server = utf8_general_ci collation_connection = utf8_general_ci character_set_client = utf8 character_set_connection = utf8 character_set_results = utf8 character_set_server = utf8 character_set_system = utf8
10.1.4. Connection Character Sets and Collations
# mysql INFORMATION_SCHEMA -tBe "SELECT * FROM GLOBAL_VARIABLES WHERE VARIABLE_NAME LIKE '%coll%' OR VARIABLE_NAME LIKE '%char%' OR VARIABLE_NAME='init_connect';" +--------------------------+-------------------------------------------------------+ | VARIABLE_NAME | VARIABLE_VALUE | +--------------------------+-------------------------------------------------------+ | CHARACTER_SETS_DIR | /usr/share/mysql/charsets/ | | CHARACTER_SET_RESULTS | utf8 | | CHARACTER_SET_CONNECTION | utf8 | | COLLATION_DATABASE | utf8_general_ci | | CHARACTER_SET_SERVER | utf8 | | COLLATION_SERVER | utf8_general_ci | | CHARACTER_SET_SYSTEM | utf8 | | CHARACTER_SET_FILESYSTEM | binary | | CHARACTER_SET_DATABASE | utf8 | | CHARACTER_SET_CLIENT | utf8 | | INIT_CONNECT | SET collation_connection = utf8_general_ci,NAMES utf8 | | COLLATION_CONNECTION | utf8_general_ci | +--------------------------+-------------------------------------------------------+ # mysql -tBe "SHOW VARIABLES WHERE VARIABLE_NAME LIKE '%coll%' OR VARIABLE_NAME LIKE '%char%' OR VARIABLE_NAME='init_connect';" +--------------------------+-------------------------------------------------------+ | Variable_name | Value | +--------------------------+-------------------------------------------------------+ | character_set_client | latin1 | | character_set_connection | latin1 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | latin1 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | | collation_connection | latin1_swedish_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | | init_connect | SET collation_connection = utf8_general_ci,NAMES utf8 | +--------------------------+-------------------------------------------------------+
To sum this up, the encoding/transcoding procedure MySQL uses to process the query and its results is a multi-step-thing:
You can find more information on the following manual pages: