Mysql字符集(2)--mysql从入门到精通(三)
上篇我们介绍了mysql字符集的种类,主要windows用gbk,mac默认utf8,还有字符集的服务器级别,数据库级别,表级别,连行都有级别,每一行都可以有不同的字符集
由于字符集和比较规则是有联系的,修改字符集后,比较规则会自动变换成相对应的,相反修改比较规则后,同理字符集也会变化。
mysql> SHOW VARIABLES LIKE 'character_set_server';
+----------------------+--------+
| Variable_name | Value |
+----------------------+--------+
| character_set_server | latin1 |
+----------------------+--------+
1 row in set (0.03 sec)
mysql> set character_set_server = 'utf8mb4';
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW VARIABLES LIKE 'character_set_server';
+----------------------+---------+
| Variable_name | Value |
+----------------------+---------+
| character_set_server | utf8mb4 |
+----------------------+---------+
1 row in set (0.00 sec)
mysql> SHOW VARIABLES LIKE 'collation_server';
+------------------+--------------------+
| Variable_name | Value |
+------------------+--------------------+
| collation_server | utf8mb4_general_ci |
+------------------+--------------------+
1 row in set (0.00 sec)
相关文章