詳細解釋參考:mysql
https://segmentfault.com/a/1190000002919949 sql
注意點:表格也是有字符集的,沒指定默認用數據庫的,數據庫建立時沒指定默認是用系統的。數據庫
而系統的字符集在配置文件是能夠設置的。segmentfault
ps:修改表格字符集的命令:socket
alter table xxx convert to character set utf8;code
my.cnf 設置:server
[client]ci
port = 3306unicode
socket = /var/run/mysqld/mysqld.sockget
default-character-set=utf8
[mysqld]
#
# * Basic Settings
#
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
default-character-set=utf8
[mysql]
default-character-set=utf8