The role of character_set_connection in MySQL

Source: Internet
Author: User

X
X
x;

We often use these three sides in the MySQL operation class, the following is probably the next function:

Character_set_client the encoding used by the client, such as GBK, UTF8 such as what you write the SQL statement is encoded.
Character_set_results the encoding of the result set returned by the query (what encoding is the data read from the database).
Character_set_connection the encoding used for the connection

There is a conversion process prior to them (see the Manual for this):

Character_set_client-character_set_connection > Internal operation character Set->character_set_results
See an article: http://www.cnblogs.com/discuss/articles/1862248.html
such as: Utf8->utf8->utf8  Gbk->utf8->utf8

Similar to the conversion of Gbk->utf8->utf8 , some students may have a question:
 character_set_client is GBK 
character_set_connection is UTF8
character _set_results is also why UTF8

does not filter the character_set_connection section, and what role it plays in this intermediate phase.
Google, http://stackoverflow.com/questions/16082480/what-is-the-purpose-of-character-set-connection
Foreigner also mentioned a kind of problem, my English is very poor, also didn't how to read, finally went to see the handbook.

found a sentence in the manual: when converting, the server uses Character_set_connection and Collation_ Connection System variables. It converts the query sent by the client from the character_set_client system variable to character_set_connection (unless the string literal has a preposition like _latin1 or _utf8). collation_connection is important for comparing text strings. For string comparisons of column values, it is not important because the column has a higher collation precedence.
Please read this phrase again and again, especially in the red section. Now I understand: We operate the database, mostly in the table, but not to say that the operation of the database must be related to the table, if the use of tables, the table and field of the character set has precedence, such as direct select Length (' Chinese '), if character_ The set_connection is UTF8 output 9, or output 6 if it is GBK. You can test it by modifying the character set variables. I think the meaning of Character_set_connection's existence is mostly similar to this kind of usage.


If there is something wrong, please correct it, or there are more statements, please say.

The role of character_set_connection in MySQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.