Today, an Incorrect string value error occurs when a Chinese character is inserted into Mysql Data.

Source: Internet
Author: User

Today, I encountered an Incorrect string value ERROR when inserting a Chinese character in Mysql. Background: part of the code insertion prompt in CMD is: ERROR 1366 (HY000 ): incorrect string value Baidu once, said it is a encoding problem, show variables like 'character % 'After viewing, found that all encoding is UTF8, there is no error to continue to check the cause, someone on the Internet said that the problem of mysql's replica set is the original article: "the original problem lies in mysql, mysql if you set the encoding set to utf8, then it can only support up to three bytes of UTF-8 encoding, the 4-byte UTF-8 character still exists, so if you create a table with utf8 Character Set exception is taken for granted. The solution is simple. Modify the character set of a field or table to utf8mb4. However, utf8mb4 is supported only after mysql 5.5.3... "The results he said must be upgraded before they can be modified. He gave up and thought it was not my problem. Later, I thought about whether to input the text encoding in CMD. I tried to set the encoding of the Client Command first and then insert it correctly! Then Baidu searched for client Encoding Problems and found the same problems with me. Solution: set names gbk // set the encoding format of the client, that is, the encoding you typed in. The client automatically converts your command to UTF8, that is, the database encoding is also UTF8 or find my In the installation directory. ini changes default-character-set = utf8 to default-character-set = gbk;

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.