Mysql error: Warning: #1366 Incorrect string value: Solution

Source: Internet
Author: User

Mysql error: Warning: #1366 Incorrect string value: the error is mainly caused by encoding problems. For example, if your gb2312 encoding contains traditional Chinese characters, this type of error will be prompted, therefore, this problem is caused by the encoding range.


I use mysql to record syslog-ng log information, and INSERT the log into MYSQL after decomposition. The INSERT statement is as follows:

Insert into logs (host, facility, priority, level, tag, datetime, program, msg)
VALUES ('auth', 'daemon', 'notice ', 'notice', '1d ', '2017-07-30 12:24:12', 'smbd ', 'smbd [45997]: xxxx opened file Public/pub/green light forest DVD13.rmvb read = Yes write = No (numopen = 14 )')

The following warning appears during the Insert Process:
Warning (Code 1366): Incorrect string value: 'xc2xccxb9xe2xc9xad... 'for column 'msg' at row 1

View the inserted data table. In the msg field, only the part before the Chinese character "Green Forest" is inserted, and the content is truncated. The content of the inserted text section msg is as follows:

Smbd [45997]: xxxx opened file Public/pub/


In fact, this encoding problem occurs because the occasional colleague sets GB2312 encoding. When some special characters are involved, the system will return an error and change it to "? .

Mysql error: Warning: #1366 Incorrect string value: solution:

It is easy to change the original encoding gb2312 to gbk encoding or utf8 encoding.

Attached: GB2312 and GBK encoding differences.

GB2312 is a Chinese character encoding set in simplified Chinese. GBK is an extension of GB2312. In addition to compatibility with GB2312, it can also display Traditional Chinese and Japanese Kana.


Experience

You can select the utf8 character set or modify the mysql database table, database field, or dataset to uft8.

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.