Change MySQL default character set to UTF-8 in my.cnf?

前端 未结 18 969
一个人的身影
一个人的身影 2020-11-22 01:55

Currently we are using the following commands in PHP to set the character set to UTF-8 in our application.

Since this is a bit of overhead, we\'d like to set this a

18条回答
  •  误落风尘
    2020-11-22 02:18

    MySQL 5.5, all you need is:

    [mysqld]
    character_set_client=utf8
    character_set_server=utf8
    collation_server=utf8_unicode_ci
    

    collation_server is optional.

    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)
    

提交回复
热议问题