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.