From:http://www.2cto.com/database/201302/189920.html
-
Mysql:charset and collation settings charset and collation have multiple levels of settings: server-level, database-level, table-level, column-level, and connection-level www.2cto.com- 1. Server-level view settings: Show global variables like ' character_set_server '; And show global variables like ' collation_server '; Modify settings: Set: in Option FILE (/ETC/MYSQL/MY.CNF) [mysqld] character_set_server=utf8 COLLATION_SERVER=UTF8_GENERAL_CI 2. Database level View settings: SELECT * from information_schema.schemata where schema_name = ' Cookbook '; Set: 1. If not explicitly set, the server-level configuration 2 is used automatically. Explicit settings: Specify when creating a library create database PlayUtf8 default CHARACTER SET latin1 COLLATE latin1_swedish_ci; ww w.2cto.com 3. Table level View settings: Show create table course; Settings: 1. If not explicitly set, automatically use database-level configuration 2. Explicit settings: Specify create table when creating tableUTF (ID int) default CHARSET=UTF8 default collate=utf8_bin; 4. Column level View settings: Show CREATE TABLE Cou rse; Settings: 1. If not explicitly set, the table-level configuration  2 is automatically used. Explicitly set: create TABLE Table1 (Column1 VARCHAR (5) CHARACTER SET latin1 COLLATE latin1_german1_ci); & Nbsp;5. Connection level View settings: show variables like ' character_set_client '; The # server uses this code to understand the statements show variables like ' character_set_connection ' sent by the client; # I don't know what it means, wait to see the MySQL source show variables like ' character_set_results '; # The server uses this encoding to echo the result set and error messages settings: The client can specify these parameters when connecting, and the server also provides a global range of values when the client does not specify these parameters. This global value is used by the server. How is this global value set? I've looked through a lot of documents and it seems like I haven't seen the setup yet (some say it's wrong to specify command-line arguments by MY.CNF, or when starting mysqld) : What code is used to connector/j transfer SQL? Answer: "The character encoding between client and server is automatically detected uponConnection. The encoding used by the driver are specified on the server using the CHARACTER_SET_SERVER system variable for server Versi ONS 4.1.0 and newer. " That is, the Character_set_server value is queried on the server side when connecting, and then the encoding used by the connection is determined. However, the official document also says, "to override the auto-detect encoding feature on the client, you can use the" characterencoding "attribute in the URL used to connect to the server. "
Settings for Mysql:charset and collation