Configuring MySQL for UTF-8

If you want to run MySQL primarily using UTF-8 then the configuration file my.cnf should contain the following directives:

[client]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_general_ci' init_connect='SET NAMES utf8' default-character-set=utf8 character-set-server = utf8 collation-server = utf8_general_
[mysql]
default-character-set=utf8

Check that things look right by running this command or by using phpMyAdmin to look at the “Variables” for the server, or some similar technique.

show variables like 'char%';

which should give a result something like:

+--------------------------+----------------------------+
| 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/ |
+--------------------------+----------------------------+

Then try:

show variables like 'col%';

which should give:

+----------------------+-----------------+
| Variable_name        | Value           |
+----------------------+-----------------+
| collation_connection | utf8_general_ci |
| collation_database   | utf8_general_ci |
| collation_server     | utf8_general_ci |
+----------------------+-----------------+
5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x

Design by Dave Mcpoland

Supported by Aussie Hosting