charset 和 collation 有多个级别的设置:服务器级、数据库级、表级、列级和连接级
2、centos下数据库是mariadb,和MysqL操作几乎一样。配置文件在etc/my.cnf.d/下配置,因为这下面的被/etc/my.cnf所包含。修改cnf文件
[MysqLd]
character_set_server=utf8
collation_server=utf8_general_ci
3、查看编码
show variables like'%char%';
SHOWVARIABLES LIKE 'COLLATION';
show charset;
SHOW CREATE DATABASE db_name;
SHOW CREATE TABLE tbl_name;
SHOW FULL COLUMNS FROM tbl_name;
set character_set_client=utf8; //客户端字符集
set character_set_connection=utf8; //链接字符集
set character_set_database=utf8; //数据库字符集
set character_set_results=utf8; //结果字符集
set character_set_server=utf8; //服务器字符集
set character_set_system=utf8; //系统字符集
set collation_connection=utf8; //链接校对
set collation_database=utf8; //数据库校对
set collation_server=utf8; //服务器校对