Database: mysql database
When the dos window inserts data into the mysql database, data cannot be inserted if it contains Chinese characters. The reason is that the character_set_client encoding is ut8 by default, while the dos window encoding is gbk by default. for example, if you specify two Chinese characters "China" to assign values to the name field, an error is returned: Incorrect string value: '\ xD6 \ xD0 \ xB9 \ xFA' for column 'name '. \ XD6 \ xD0 \ xB9 \ xFA is the hexadecimal code of gbk corresponding to "China. UTF-8 uses three bytes to indicate a Chinese character. The 'China' character must have six bytes, which is clearly identified as a problem. Therefore, the dos window table inserts a record containing Chinese characters. Remember: set character_set_client = gbk; this sentence is equivalent to notifying the database. The input character is encoded as "gbk, in this way, automatic conversion can be achieved and insertion is successful.
The records in the dos interface display table may also contain Chinese garbled characters. Remember to set character_set_results = gbk. This is equivalent to notifying the database display interface to adopt gbk encoding, so that Chinese characters can be normally displayed.
You can enter the command: show variables like "chara %"; to display the encoding used in all aspects of the current database system.