Mysql garbled solution and mysql garbled Solution

Source: Internet
Author: User

Mysql garbled solution and mysql garbled Solution

Symptom: the following error is reported when the data inserted to the database contains Chinese characters.

The cause is: the default encoding of the computer is gbk, And the encoding method provided by the mysql client is utf8. The two encoding types are inconsistent. Check the current mysql encoding: show variables like 'character % '. For example, the solution is to change the client encoding provided by mysql to gbk and set the client encoding: set character_set_client = gbk. Now you can insert Chinese data, however, when you select * from user, you find that the Chinese data you just inserted is garbled because the default encoding of the computer system is gbk, while that of the mysql result set is utf8, the solution is to set the mysql result set encoding to gbk to set the result set encoding: set character_set_results = gbk; query the database again
Note: The above operations only apply to the current client to modify the encoding thoroughly: Find my in the installation file. in the INI file, find the default-character-set = utf8 line and change utf8 to gbk, which means that all the encoding related to the client is provided to the Cheng gbk to query the limit set again. In the future, you can store Chinese characters on the display at will.



From Weizhi note (Wiz)



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.