标签:
mysql> SHOW VARIABLES WHERE Variable_name LIKE ‘character\_set\_%‘ OR Variable_name LIKE ‘collation%‘; +--------------------------+-----------------+ | Variable_name | Value | +--------------------------+-----------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | collation_connection | utf8_general_ci | | collation_database | utf8_general_ci | | collation_server | utf8_general_ci | +--------------------------+-----------------+ 10 rows in set (0.20 sec)
mysql> SET character_set_client = gbk; Query OK, 0 rows affected (0.31 sec) mysql> SET character_set_connection=gbk ; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_database=utf8mb4; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_filesystem=binary; Query OK, 0 rows affected (0.00 sec) mysql> set character_set_results=gbk; Query OK, 0 rows affected (0.00 sec)
mysql> set character_set_system=utf8;
ERROR 1238 (HY000): Variable ‘character_set_system‘ is a read only variable
mysql> set names gbk; 它相当于下面的三句指令: SET character_set_client = gbk; SET character_set_results = gbk; SET character_set_connection = gbk;
SET NAMES ‘charset_name
‘ COLLATE ‘collation_name
‘
[client] //通过连接器连接 EG:PHP
[mysql] //mysql程序登陆时的字符集
default-character-set = gbk
//等价
--SET character_set_client = gbk;
--SET character_set_results = gbk;
--SET character_set_connection = gbk;
#character_set_system=utf8mb4 #character_set_client=utf8mb4 #character_set_connection=utf8mb4 #character_set_database=utf8mb4 #character_set_results=utf8mb4 // #代表相应变量不能设置在这个区中,报错,mysql登陆报错
[mysqld] //mysqld起动时设置字符集
character_set_filesystem=binary
character-set-server=utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=‘set autocommit=0; set names gbk;‘ //root 用户不会执行
#character_set_system=utf8mb4
#character_set_client=utf8mb4
#character_set_connection=utf8mb4 //#代表相应变量不能设置在这个区中,mysqld 起动报错
#character_set_database=utf8mb4
#character_set_results=utf8mb4
[]
mysql> select * from t1; +------------+-----------------+---------------------+ | cur_user | n_user | in_time | +------------+-----------------+---------------------+ | @localhost | mysql@localhost | 2016-07-05 00:25:02 | +------------+-----------------+---------------------+ 1 row in set (0.19 sec) mysql> ALTER TABLE t1 MODIFY cur_user CHAR(50) CHARACTER SET sjis; mysql> show create table t1; CREATE TABLE `t1` ( `cur_user` char(50) CHARACTER SET sjis DEFAULT NULL, `n_user` varchar(100) CHARACTER SET utf8 DEFAULT NULL, `in_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4
移动设备 表情符号的数据库存储 与 utf8 与utf8mb4 字符集
标签:
原文地址:http://www.cnblogs.com/zengkefu/p/5644593.html