character_set_client 在客户端发出
sql语句所使用的字符集。
collat
ion_connection 连接所使用的字符集校对规则
character_set_results 返回到客户端的查询结果集(例如查询结果或错误信息)所使用的字符集
character_set_connection The character set used for literals that do not have a character set introducer and for number-to-string conversion
--指定客户端当前会话使用的字符集
SET NAMES会同时更改character_set_client, character_set_connection,character_set_results这三个会话参数的字符集
Mysql>
set names utf8;
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like '%character%';
+--------------------------+-----------------------+
| Variable_name | Value |
+--------------------------+-----------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /data/share/charsets/ |
+--------------------------+-----------------------+
8 rows in set (0.00 sec)
SET CHARACTER SET会更改character_set_client、character_set_results,同时将character_set_connection设置为character_set_database这个系统参数的值
mysql>
set character set latin2;
Query OK, 0 rows affected (0.01 sec)
mysql> show variables like '%character%';
+--------------------------+-----------------------+
| Variable_name | Value |
+--------------------------+-----------------------+
| character_set_client | latin2 |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | latin2 |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /data/share/charsets/ |
+--------------------------+-----------------------+
8 rows in set (0.00 sec)
0