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