There are many types of MySQL character sets that affect programming, mainly client character sets and database character sets.
Common Operations in databases are to save data and read data. In this process, there seems to be nothing to do with the MySQL 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 MySQL 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 MySQL Character Set Data table)
- show table status from tablename like '%countries%';
3. view the data column (column) of the MySQL character set ).
- show full columns from tablename;
4. view the character sets supported by currently installed MySQL.
- Thoughts on MySQL character set architecture
- Introduction to MySQL Character Set
- How to lock MySQL database tables
- How to fix MySQL database tables
- Test the replication feature of New MySQL features (1)