MySQL Variables character_set_client 数据库 参数变量解释及正确配置使用
本站中文解释
character_set_client参数用来设置客户端默认的字符集。当客户端从MySQL服务器端获取信息时,MySQL服务器端会将数据转换为该设置的字符集,当客户端将信息发送到MySQL服务器端时,MySQL服务端会将该设置的字符集当做客户端的字符集来处理。
设置character_set_client的方法有两种,即在my.cnf文件中设置,或者在MySQL客户端连接数据库之前执行 SET NAMES 命令设置,例如:
SET NAMES utf8; 或 SET NAMES gbk;
官方英文解释
character_set_client
System Variable | character_set_client |
---|---|
Scope | Global, Session |
Dynamic | Yes |
Type | String |
Default Value | utf8 |
The character set for statements that arrive from the client.
The session value of this variable is set using the character
set requested by the client when the client connects to the
server. (Many clients support a
--default-character-set
option to enable this
character set to be specified explicitly. See also
Section 10.4, “Connection Character Sets and Collations”.) The global value of the
variable is used to set the session value in cases when the
client-requested value is unknown or not available, or the
server is configured to ignore client requests:
-
The client requests a character set not known to the
server. For example, a Japanese-enabled client requests
sjis
when connecting to a server not
configured withsjis
support. -
The client is from a version of MySQL older than MySQL
4.1, and thus does not request a character set. -
mysqld was started with the
--skip-character-set-client-handshake
option, which causes it to ignore client character set
configuration. This reproduces MySQL 4.0 behavior and is
useful should you wish to upgrade the server without
upgrading all the clients.
Some character sets cannot be used as the client character
set. Attempting to use them as the
character_set_client
value
produces an error. See
Impermissible Client Character Sets.