Not much, first.
Analysis:
Set names UTF8 before the
Character_set_client | Gbk
character_set_connection| Gbk
Character_set_results | Gbk
Set names UTF8 later,
Character_set_client | Utf8
character_set_connection| Utf8
Character_set_results | Utf8
about character sets can be referenced MySQL Chinese Handbook
Address: http://dev.mysql.com/doc/refman/5.1/zh/charset.html#charset-connection
Here are some excerpts:
Character set and proofing rule variables are also involved in connection processing for clients and servers. Each client has a connection-related character set and proofing rule variables.
consider what is a " Connection " : It's what you do when you connect to a server. The client sends an SQL statement, such as a query, to the server via a connection. The server sends a response over a connection to the client, such as a result set. For client connections, this can cause problems with connection character sets and Proofing rules that can be resolved by system variables:
· When the query leaves the client, what character set is used in the query?
Server Use character_set_client variable as the character set used in the query sent by the client.
· What kind of character set should the server convert to after it receives a query?
when converting, the server usescharacter_set_connectionand thecollation_connectionSystem variables. It sends the query sent by the client fromcharacter_set_clientsystem variables are converted tocharacter_set_connection(unless the string literal has an image_latin1or_utf8of the cited prepositions). collation_connectionis important for comparing text strings. For string comparisons of column values, it is not important because the column has a higherProofing Rule Precedence.
· What character set should the server convert to before sending a result set or returning an error message to the client?
Character_set_results variables instruct the server to return query results to the character set used by the client. Includes result data, such as column values and result metadata, such as column names.
You can adjust the settings of these variables, or you can rely on the default values (so that you may skip this chapter).
There are two statements that affect the connection character set:
SET NAMES 'charset_name'
SET CHARACTERSETcharset_name
SET NAMES 'x' A statement is equivalent to these three statements:
mysql>setcharacter_set_client =x;
mysql>setcharacter_set_results =x;
mysql>setcharacter_set_connection =x;
so say:
Set names UTF8 specifies that the encoding rules for passing characters between the client and the server are UTF8 .
ModifyMYSQLdefault Encoding
MYSQL The default encoding is Latin1 , do not support Chinese, to modify the default encoding, you need to modify My.ini file
[Client] Increase Default-character-set=utf8
[MySQL] Increase Default-character-set=utf8
[Mysqld] Increase
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '
cmd the Operation MySQL garbled need to note cmd Coding
View the current code page, if the current code page is GBK then need Set names GBK can be guaranteed not garbled.
chcp 65001/936 Modify the code page. Perfect solution to garbled problems.
MySQL set NAMES UTF8 detailed (garbled principle)