How to display Chinese characters in a database table in the dos window of a mysql database

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.