Today, I encountered a Chinese character "Incorrectstringvalue_MySQL" in Mysql inserting data.

Source: Internet
Author: User
Today, we encountered the Incorrectstringvalue error bitsCN.com when inserting data from Mysql.

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

Background: directly insert data by typing code in CMD

Part of the prompt is truncated to: ERROR 1366 (HY000): Incorrect string value

Baidu once said it was a coding problem. after checking show variables like 'character % ', we found that all the codes are UTF8 and there is no error.

Continue to check the cause. some people on the Internet say that the mysql replica set has the following problems:

"The original problem lies in mysql, mysql if set encoding set to utf8 so it can support up to 3 bytes of UTF-8 encoding, and 4 bytes of UTF-8 characters still exist, in this way, if you use the utf8 character set when creating a table, it is a matter of course.

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... "

According to his remarks, these results can be modified only after being upgraded, and I gave up decisively. I also feel that they are not my problems. 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 or UTF8.

Or find my. ini in the installation directory.

Change default-character-set = utf8 to default-character-set = gbk;

BitsCN.com

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.