MySQL Chinese insert error Incorrectstringvalue: & amp; #39; \ xCC \ xEC \ xB2 \ xC5 & amp; #39;

Source: Internet
Author: User

MySQL Chinese insert error Incorrectstringvalue: & #39; \ xCC \ xEC \ xB2 \ xC5 & #39;
Preface: failed to input Chinese characters. Error: Incorrect string value: '\ xCC \ xEC \ xB2 \ xC5', as shown below:

1. Check the character set of the database. It is utf8 and displayed normally.
Mysql> show variables like '% char % ';
2. view the character set of the connected client,
Vim/etc/my. cnf
3. Run the following command in the Query window through the sqlyog remote tool:
Set names utf8;
Query the t table in the sqlyog window. Chinese characters are also displayed, as shown in:
In this case, we can infer where the problem is. The sqlyog client can normally enter Chinese characters to display Chinese characters, but the mysql window in linux cannot. Check the character set settings of the linux operating system on the OS layer.

4. Check the character set of the linux OS where the mysql server is located.
[Root @ data01 ~] # Cat/etc/sysconfig/i18n
Then restart linux, restart mysql, or export LANG = "zh_CN.UTF-8 ";
[Root @ data01 ~] # Service mysqld5612 restart
5. Test: For data unification, linux re-sets the character set and then re-logs in to execute the Chinese input operation. Therefore, after the table is drop, create still reports an error. If the table cannot be entered in Chinese, encoding problems may occur.
Mysql> insert into t SELECT 4 AS a, 'Fourth Dream 'AS B;
6. Check the connection of the xshell tool. In the Terminal-> Encoding: drop-down box next to it, it is found that it is default and is not set to utf8 Encoding, as shown in:
Then modify it to utf8, as shown below:
Then, you can enter Chinese as follows:
Mysql> insert into t SELECT 4 AS a, 'Fourth Dream 'AS B;
7. set names utf8; invalid reason

PS: In summary, mysql has two concepts: server-side encoding and client-side encoding. My server-side encoding is utf8, my MYSQL client (not the mysql window interface, but the client tool xshell that remotely connects to the mysql server) is obviously a GBK or ansi environment, so it must be set to utf8 before conversion is successful.

For Chinese garbled characters, check the following three places:
1. character encoding of the mysql window (set the character set of the remote tool connected by xshell );
2. database character encoding (show variables like '% char %'); 3. linux operating system character encoding (echo $ LANG );

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.