Mysql statement: set names UTF8 has always known only mysql_query ("set names UTF8"); it sets the database encoding, but it has never been clear what "set names UTF8" is. It is not until today that the set names... is a mysql statement. I really feel that my homework has not been completed yet, and my current knowledge reserves are scarce. Write down the relevant information: www.2cto.com 1. set names 'charset _ name' set names displays the character sets used in the SQL statements sent by the client. Therefore, the set names 'cp1251 'statement tells the server to use the character SET cp1251 for future information sent from this client ". It also specifies the character set for the results sent from the server back to the client. (For example, if you use a SELECT statement, it indicates the character set used by the column value .) 2. Connecting character sets and checking (1) Some character sets and checking rule system variables are related to the interaction between the client and the server. · Server character sets and verification rules can be used as the value of character_set_server and collation_server variables. · Default database character sets and verification rules can be used as character_set_database and collation_database variable values. Character Set and checking rule variables are also involved in client-to-server connection. Each client has a connection-related character set and checking rule variable. Www.2cto.com (2) considers what is a "connection": what it does when connecting to the server. The client sends SQL statements, such as queries, to the server through connections. The server sends a response to the client through a connection, such as a result set. For client connection, this will cause some problems about the character set and proofreading rules of the connection. These problems can be solved through system variables: (3) when the query leaves the client, which character set is used in the query? The server uses the character_set_client variable as the character set used in the query sent by the client. (4) What character set should the server convert to after receiving the query? During conversion, 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 text has a prefix like _ latin1 or _ utf8 ). Collation_connection is important for comparing text strings. It is not important to compare the column value strings because the column has a higher priority for checking rules. (5) which character set should the server convert to before sending the result set or returning the error message to the client? The character_set_results variable indicates that the server returns the query result to the character set used by the client. Includes result data, such as column values and result metadata (such as column names ). Example of www.2cto.com: mysql_query ("set names 'utf8'"); // use utf8 encoding;