There are many types of character sets in the MySQL database, and the main impact on programming is the client Character Set and database character set (there is also a server character set that doesn't know what to do ).
Common Operations in databases are to save and read data. In this process, the garbled characters seem to have nothing to do with the database character set. We only need to ensure that the character set selected during the write operation is consistent with the character set selected during the read operation, that is, we only need to ensure that the client character set for the two operations is consistent.
The client Character Set settings are different based on different client methods:
1. Use the console to connect and set it in the client item in the my. ini file;
2. Use EMS to connect. Use EMS to connect to the configured Character Set first. The settings in my. ini file are used by default;
3. For jdbc connection, specify the following in the connection string:
Jdbc: mysql: /// 192.168.3.99: 3306/test? UseUnicode = true &; characterEncoding = gbk
During writing, Mysq converts the character set specified by the client to the database character set and saves it to the data file. During reading, the database character set is converted to the character set specified by the client and displayed to the client, setting the client character set is the same as that of the database. The obvious benefit is that the conversion performance is free of consumption. In addition, if you consider the future database migration, setting the database character set to the character set supported by most databases saves a lot of trouble.
Several Character Set-related commands:
1. View MySQL database server Character Set, database character set, and client Character Set
Show variables like '% char % ';
Character_set_client, client Character Set
Character_set_database, database Character Set
Character_set_server, server Character Set
2. view the character set of the MySQL DATA table
Show table status from tablename like '% countries % ';
3. view the character set of the MySQL DATA column (column.
Show full columns from tablename;
4. view the character sets supported by currently installed MySQL.