mysql> SHOW VARIABLES LIKE ’character_set_system’; +----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | character_set_system | utf8 | +----------------------+-------+ 

Storage of metadata using Unicode does not  mean that the server returns headers of columns and the results of DESCRIBE  functions in the character_set_system  character set by default. When you use SELECT column1 FROM t , the name column1  itself is returned from the server to the client in the character set determined by the value of the character_set_results  system variable, which has a default value of utf8mb4 . If you want the server to pass metadata results back in a different character set, use the SET NAMES  statement to force the server to perform character set conversion. SET NAMES sets the character_set_results  and other related system variables. (See Section 10.4, “Connection Character Sets and Collations” .) Alternatively, a client program can perform the conversion after receiving the result from the server. It is more efficient for the client to perform the conversion, but this option is not always available for all clients. 

If character_set_results  is set to NULL , no conversion is performed and the server returns metadata using its original character set (the set indicated by character_set_system ). 

Error messages returned from the server to the client are converted to the client character set automatically, as with metadata. 

If you are using (for example) the USER()  function for comparison or assignment within a single statement, don’t worry. MySQL performs some automatic conversion for you. 

SELECT * FROM t1 WHERE USER() = latin1_column; 

This works because the contents of latin1_column  are automatically converted to UTF-8 before the comparison. 

INSERT INTO t1 (latin1_column) SELECT USER(); 

This works because the contents of USER()  are automatically converted to latin1  before the assignment. 

Although automatic conversion is not in the SQL standard, the standard does say that every character set is (in terms of supported characters) a “subset”  of Unicode. Because it is a well-known principle that “what applies to a superset can apply to a subset,”  we believe that a collation for Unicode can apply for comparisons with non-Unicode strings. For more information about coercion of strings, see Section 10.8.4, “Collation Coercibility in Expressions” . 

## 10.3 Specifying Character Sets and Collations 

There are default settings for character sets and collations at four levels: server, database, table, and column. The description in the following sections may appear complex, but it has been found in practice that multiple-level defaulting leads to natural and obvious results. 

CHARACTER SET  is used in clauses that specify a character set. CHARSET  can be used as a synonym for CHARACTER SET . 

Character set issues affect not only data storage, but also communication between client programs and the MySQL server. If you want the client program to communicate with the server using a character set different from the default, you’ll need to indicate which one. For example, to use the utf8mb4  Unicode character set, issue this statement after connecting to the server: 

SET NAMES ’utf8mb4’; 

