Task: on a MySQL 5.5 server (this probably works on lower versions too) change the system CHARACTER SET and COLLATION settings.
1) Edit the my.cnf file. Add (or change the existing) entries to look like this:
character-set-server = utf8
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
(accordingly, replace utf8 with the encoding you need).
2) Restart the MySQL server.
3) Verify. Log in to the server console and run:
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| 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)
and also:
mysql> show variables like 'collat%';
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
3 rows in set (0.00 sec)
Relevant for: MySQL 5.5
Comments