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

前端 未结 18 955
一个人的身影
一个人的身影 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:07

    To set the default to UTF-8, you want to add the following to my.cnf

    [client]
    default-character-set=utf8
    
    [mysql]
    default-character-set=utf8
    
    
    [mysqld]
    collation-server = utf8_unicode_ci
    init-connect='SET NAMES utf8'
    character-set-server = utf8
    

    If you want to change the character set for an existing DB, let me know... your question didn't specify it directly so I am not sure if that's what you want to do.

提交回复
热议问题