mysql命令行cmd环境下转编码简介 |
本文标签:mysql命令行 mysql命令行相信大家都有一些了解,下面就为您介绍mysql命令行cmd环境下转编码的相关知识,供您参考学习之用 。 大家都知道 以下从MySQL5.0官方文档上摘录了相关内容,并翻译,说明了相关系统变量的用处: What character set is the statement in when it leaves the client? The server takes the character_set_client system variable to be the character set in which statements are sent by the client. What character set should the server translate a statement to after receiving it? For this, the server uses the character_set_connection and collation_connection system variables. It converts statements sent by the client from character_set_client to character_set_connection (except for string literals that have an introducer such as _latin1 or _utf8). collation_connection is important for comparisons of literal strings. For comparisons of strings with column values, collation_connection does not matter because columns have their own collation, which has a higher collation precedence. What character set should the server translate to before shipping result sets or error messages back to the client? The character_set_results system variable indicates the character set in which the server returns query results to the client. This includes result data such as column values, and result metadata such as column names. If you are using the mysql client with auto-reconnect enabled (which is not recommended), it is preferable to use the charset command rather than SET NAMES. For example: mysql> charset utf8 The charset command issues a SET NAMES statement, and also changes the default character set that is used if mysql reconnects after the connection has dropped. The database character set and collation are used as default values if the table character set and collation are not specified in CREATE TABLE statements. They have no other purpose. The character set and collation for the default database can be determined from the values of the character_set_database and collation_database system variables. The server sets these variables whenever the default database changes. If there is no default database, the variables have the same value as the corresponding server-level system variables, character_set_server and collation_server. The table character set and collation are used as default values if the column character set and collation are not specified in individual column definitions. The table character set and collation are MySQL extensions; there are no such things in standard SQL. Every “character” column (that is, a column of type CHAR, VARCHAR, or TEXT) has a column character set and a column collation. Every character string literal has a character set and a collation. A character string literal may have an optional character set introducer and COLLATE clause: [_charset_name]string [COLLATE collation_name] Examples: SELECT string;
|