MySQL Error: Warning: #1366 Incorrect string value: Workaround

Source: Internet
Author: User
Tags character set mysql database truncated


I use MySQL to record syslog-ng log information, after the decomposition of the log inserted into the Mysql,insert statement as follows:

INSERT into logs (host, facility, priority, level, tag, datetime, program, MSG)
VALUES (' PHY ', ' daemon ', ' notice ', ' notice ', ' 1d ', ' 2008-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 appear during the insert process:
Warning (Code 1366): Incorrect string value: ' Xc2xccxb9xe2xc9xad ... ' for column ' msg ' at row 1

To view the inserted data table, the MSG field is only partially inserted before the Chinese character "Green Forest", and the content is truncated, and the inserted paragraph MSG is as follows:

SMBD[45997]: xxxx opened file public/pub/


This is actually a coding problem, I met the colleague is the code set GB2312 caused, when it involves some special characters, will appear truncated, will be the error, change to "? "For display.

MySQL Error: Warning: #1366 Incorrect String value: Workaround:

It is simple to change the original encoding gb2312 to: GBK encoding, or UTF8 encoding.

Attached: GB2312 and GBK coding differences.

GB2312 is a Chinese regulation of the encoding, can also be said to be Simplified Chinese character set code; GBK is an extension of GB2312, which, in addition to compatible GB2312, can display traditional Chinese and kana in Japanese


Experience

The UTF8 character set is chosen or the MySQL database table or database field or dataset can be modified 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.