Di Default molte distribuzioni Linux , installano mysql con default character set settano a latin1.
Per modificare questo valore e impostarlo in utf8 :
alla fine di [client] section, aggiungi:
default-character-set = utf8
alla fine di [mysqld] section, aggiungi:
character-set-server = utf8
restart mysql
> sudo /etc/init.d/mysql restart
per verificare :
> mysql -u root -p mysql> show variables like '%char%';
dovresti vedere :
+--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)
default-character-set = utf8
at the end of [mysqld] section, add:
character-set-server = utf8
then restart your mysql server:
> sudo /etc/init.d/mysql restart
and make sure it says OK with
* Starting MySQL database server mysqld
then check if it all works out
> mysql -u root -p mysql> show variables like '%char%';
you should see the following:
+--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec)