[client]
default-character-set=utf8
(非必要)
[mysqld]
character-set-server=utf8
collation-server=utf8_general_ci (非必要)
[mysql]
default-character-set=utf8 (非必要)
character-set-server = latin1
collation-server = latin1_swedish_ci
指定 character set ,但沒指定 collation , collation 會依據 character set 自動搭配,因此 collation 通常可不需指定。可查詢 mysql share/charsets/ 目錄下 Index.xml 檔。
ci
表示 case-insensitive , cs
表示 case-sensitive 。
mysql>SHOW VARIABLES LIKE 'char%';
+--------------------------+--------------------------------+ | Variable_name | Value | +--------------------------+--------------------------------+ | character_set_database | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | +--------------------------+--------------------------------+
mysql>SHOW VARIABLES LIKE 'coll%';
+----------------------+-----------------+ | Variable_name | Value | +----------------------+-----------------+ | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +----------------------+-----------------+
mysql>SHOW COLLATION LIKE 'utf8%';
各個資料庫目錄下的 db.opt 檔,以文字編輯器開啓。
更新日期: