본문 바로가기
정보기술/웹&데이터베이스

MySQL Server Character Set and Collation

by fermi 2010. 5. 28.
참고: http://dev.mysql.com/doc/refman/5.5/en/charset-server.html
http://dev.mysql.com/doc/refman/5.5/en/server-options.html


MySQL Server has a server character set and a server collation. These can be set at server startup on the command line or in an option file and changed at runtime.

Initially, the server character set and collation depend on the options that you use when you start mysqld. You can use --character-set-server for the character set. Along with it, you can add --collation-server for the collation. If you don't specify a character set, that is the same as saying --character-set-server=latin1. If you specify only a character set (for example, latin1) but not a collation, that is the same as saying --character-set-server=latin1 --collation-server=latin1_swedish_ci because latin1_swedish_ci is the default collation for latin1. Therefore, the following three commands all have the same effect:

shell> mysqld
shell> mysqld --character-set-server=latin1
shell> mysqld --character-set-server=latin1 \
--collation-server=latin1_swedish_ci

Here's an example for the [mysqld] section of your my.cnf:

skip-character-set-client-handshake <- 필요한지 확인 필요
collation-server=utf8_unicode_ci
character-set-server=utf8

여러 설정 사례를 찾아보니 character set & collation 과 관련된 변수들은
skip-character-set-client-handshake
default-character-set
default-collation
character-set-server
collation-server
등이 있으나 실제 설정을 통하여 MySQL 5.1.41-3ubuntu12.1 및 mysql-admin 툴을 이용해서 확인해 본 결과 아래와 같이 설정하였을 때 성공함, skip-character-set-client-handshake 설정이 없으면 default-character 가 utf8으로 설정되어 있어도 client가 다른 설정을 사용할 경우 작동하지 않기 때문에, 반드시 skip-character-set-client-handshake 을 추가하여야 작동하였음

#
# * Character Set and Collation
#
skip-character-set-client-handshake
# Set the default character set.
default-character-set=utf8
# Set the default collation.
default-collation=utf8_unicode_ci