时间:2022-07-02 10:31:31 | 栏目:Mysql | 点击:次
character
是各种文字和符号的总称character code
是计算机针对各种符号,在计算机中的一种二进制存储代号character set
是多个字符的集合常见的字符集:
-- 设置客户端字符集编码 set names gbk; -- 查看字符集编码设置 show variables like 'character_set_%'; +--------------------------+------------+ | Variable_name | Value | +---------+-----------------------------+ | character_set_client | gbk | | character_set_connection | gbk | | character_set_database | utf8mb4 | | character_set_filesystem | binary | | character_set_results | gbk | | character_set_server | utf8mb4 | | character_set_system | utf8 | | character_sets_dir | /usr/local/Cellar/mysql/8.0.16/share/mysql/charsets/ | +--------------------------+------------+ -- 插入中文字符 insert into tb_teacher (name, age) values ('张三', 23);
MySQL 与 MySQLd 之间有三层:
client
server
collection
变量:
character_set_client
客户端character_set_connection
连接层character_set_database
数据库character_set_results
结果集修改变量:
set 变量名 = 值; -- 修改单个变量 set character_set_client = gbk; -- 设置字符集 set names gbk; -- 等价于 set character_set_client = gbk; // 让服务器识别客户端传过去的数据 set character_set_connection = gbk; // 更好的帮助客户端与服务器端之间惊醒字符集转换 set character_set_results = gbk; // 告诉客户端服务器返回的数据