Skip to content

Instantly share code, notes, and snippets.

@jjangga0214
Last active May 31, 2018 01:02
Show Gist options
  • Save jjangga0214/8884b4c3f2a598743198f5a362ce3d0f to your computer and use it in GitHub Desktop.
Save jjangga0214/8884b4c3f2a598743198f5a362ce3d0f to your computer and use it in GitHub Desktop.
mysql에 (특히 한글 지원을 위해서) utf8 로 설정하는 것을 설명한다.

Mysql utf8 설정

(주로 설치 직후) 설정을 수정한다.

/etc/mysql/my.cnf

#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
# 
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

#
# * IMPORTANT: Additional settings that can override those from this file!
#   The files must end with '.cnf', otherwise they'll be ignored.
#

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/

#[mysqld]
#collation-server = utf8_general_ci
#character-set-server = utf8
#skip-character-set-client-handshake

[client]
default-character-set = utf8

[mysqld] 
character-set-client-handshake=FALSE 
init_connect="SET collation_connection = utf8_general_ci"
init_connect="SET NAMES utf8" 
character-set-server = utf8 
collation-server = utf8_general_ci 
lower_case_table_names = 1
max_allowed_packet = 1024M

[mysqldump] 
default-character-set = utf8 

[mysql] 
default-character-set = utf8

database 생성시 character set 을 지정한다.

default chracter set 은 optional 이지만, 한글을 위해 아래와 같이 설정한다.

create database ${database-name} default chracter set utf8;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment