1.查看mysql支持的字符集
SHOW CHARACTER SET;
2.通过修改表
USER information_schema;
SELECT * FROM CHARACTER_SETS;
3.show+like模糊查询
show character set where charset like 'latin1';
4.通过查看information_schema数据库下character_sets表
DESC information_schema.CHARACTER_SETS;
select character_set_name,default_collate_name,description,maxlen from information_schema.character_sets;
5.查看字符集变量
SHOW VARIABLES LIKE 'character%';
6.变量的含义
character_set_client:客户端来源数据使用的字符集;
character_set_connection=utf8:连接层字符集
character_set_results=utf8:查询结果字符集
character_set_database=utf8:当前选中数据库的默认字符集
character_set_server=utf8:默认的内部操作字符集
character_set_system=utf8:系统元数据(字段名等)字符集
7.mysql字符集传递:
a 我们的字段没有设置字符集,因此使用表的数据集
b 我们的表没有指定字符集,默认使用数据库存的字符集
c 我们的数据库在创建的时候没有指定字符集,因此使用character_set_server设定值
d 我们没有特意去修改character_set_server的指定字符集,因此使用mysql默认
e mysql默认的字符集是latin1,character_set_connection的字符集是UTF-8,插入中文出现乱码