"Copy" and "Encode" the encoding problem in MySQL replication

Source: Internet
Author: User

Coding background Knowledge

Latin-1, full name ISO 8859-1 Latin 1 for ASCII Latin extended backwards compatible with ASCII, whose encoding range is exactly the same as the ASCII between 0x00-0xff,0x00-0x7f , 0x80-0x9f is the control character between the 0xa0-0xff and the text symbol.

ASCII There's nothing to say 0x00–0x7f the earth will look into the table

GBK: Check Table http://ff.163.com/newflyff/gbk-list/

UTF8 Encoding: a landing implementation of a Unicode table ( including transfer < size end >, Byte storage, interpretation, etc. )

Remember: GBK if you want to convert to UTF8 , there is no binary rule, is generally through
GBK table--àunicode corresponding pit-à according to the rules become-: UTF8.

Unicode: Remember that in the Unicode character table, every word in each language occupies a hole. Unicode encoding is represented by two bytes (common enough) or four bytes (such as Oracle) .

The conversion of UNICODE to UTF-8 is

1 First determine the number of UTF-8 encoded bytes required for the encoding

2 then fill in the blanks with UNICODE encoded bits from low to high, followed by rules, and the insufficient highs are supplemented with 0

1. Error ' Incorrect string value: ' \xe7\xb3\xbb\xe7\xbb\x9f ... '

Last_errno:1366Last_error:error'Incorrect string value:'\xe7\xb3\xbb\xe7\xbb\x9f ...'For column'Content'At Row 1'  onQuery.Default Database:'IBank'. Query:'Update bk_web_close Set createtime=' the- .- -  -: -: -', Updatetime=' the- ,- -  +: Geneva: to', version=8, content='<Div>\ r \ n System upgrade, please suspend use.</Div>\ r \ n', Status=1 where id=1 and version=7'

View Binlog:

UpdateBk_web_closeSetCreatetime='2014-06-14 14:30:30', UpdateTime='2014-08-14 21:02:31', version=8, content='<div>\r\n <E7><B3><BB><E7><BB><9F><E5><8D><87> <E7><BA><A7><E4><B8><AD><EF><BC><8C><E8><AF> <B7><E6><9A><82><E5><81><9C><E4><BD><BF><E7> <94><a8><e3><80><82></div>\r\n', status=1 whereId=1  andVersion=7/*!*/;

2. Similar errors

Incorrect string value:'\xb2\xe1'  for column 'title'At row1'On query. Default Database:'Db_puyitou'. Query:'UpdateCm_newsSetHtmlstatus=1, HTMLName=0x3230313430373237323435302e68746d, TemplateID= -, ColumnID=7Userid=0x61646d696e, Subcolumnid= A, title=0xd7a2b2e1, keyword="", description="", Source="", Content=0x3c703e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbcecce52c53696d53756e3b20434f4c4f523a20233539353935393b2 0464f4e542d53495a453a2031347078223ea2d9203c2f7370616e3e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbcecce52c5369 6d53756e3b20434f4c4f523a20233539353935393b20464f4e542d53495a453a2031347078223eb5e3bbf7d3d2c9cfbdc7a1bed7a2b2e1a1bfa3acb8f 9beddcce1cabecceed0b4d7a2b2e1d0c5cfa2a1a33c2f7370616e3e3c2f703e3c703e3c7370616e207374796c653d22464f4e542d46414d494c593a20 Cbcecce52c53696d53756e3b20434f4c4f523a20233539353935393b20464f4e542d53495a453a2031347078223ed7a2a3bad3c3bba7c3fbd0ebceaac ad6bbfabac5a1a33c2f7370616e3e3c2f703e3c70207374796c653d22544558542d414c49474e3a2063656e7465722

View Binlog

UpdateCm_newsSetHtmlstatus=1, HTMLName=0x3230313430373237323435302e68746d, TemplateID= -, ColumnID=7Userid=0x61646d696e, Subcolumnid= A, title=0xd7a2b2e1, keyword="", description="", Source="", Content=0x3c703e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbcecce52c53696d53756e3b20434f4c4f523a20233539353935393b20464 F4e542d53495a453a2031347078223ea2d9203c2f7370616e3e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbcecce52c53696d53 756e3b20434f4c4f523a20233539353935393b20464f4e542d53495a453a2031347078223eb5e3bbf7d3d2c9cfbdc7a1bed7a2b2e1a1bfa3acb8f9bed Dcce1cabecceed0b4d7a2b2e1d0c5cfa2a1a33c2f7370616e3e3c2f703e3c703e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbce cce52c53696d53756e3b20434f4c4f523a20233539353935393b20464f4e542d53495a453a2031347078223ed7a2a3bad3c3bba7c3fbd0ebceaacad6b bfabac5a1a33c2f7370616e3e3c2f703e3c70207374796c653d22544558542d414c49474e3a2063656e746572223e3c7370616e207374796c653d2246 4f4e542d46414d494c593a20cbcecce52c53696d53756e3b20434f4c4f523a20233539353935393b20464f4e542d53495a453a2031347078223e3c2f7 370616e3e3c2f703e3c70207374796c653d22544558542d414c49474e3a2063656e746572223e3c7370616e207374796c653d22464f4e542d46414d49 4c593a20cbcecce52c53696d53756e3b20434f4c4f523a20233539353935393b20464f4e542d53495a453a2031347078223e3c2f7370616e3e3c2f703e3c70207374796c653d22544558542d4 14c49474e3a2063656e746572223e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbcecce52c53696d53756e223e3c7370616e2073 74796c653d22464f4e542d46414d494c593a20cea2c8edd1c5bada2c4d6963726f736f66742059614865693b20434f4c4f523a20233539353935393b2 0464f4e542d53495a453a2031347078223e3c696d67207374796c653d2257494454483a2036303070783b204845494748543a20333133707822207469 746c653d2233332e504e472220626f726465723d223022206873706163653d223022207372633d22687474703a2f2f3230332e3139352e3230322e373 53a383038302f636d2f6a732f75656469746f72315f335f352f6a73702f75656469746f72696d67732f32303134303830372f39343131343037333737 3631353530382e504e47222077696474683d2236303022206865696768743d22333133222f3e3c2f7370616e3e266e6273703b3c2f7370616e3e3c2f7 03e3c703e3c7370616e207374796c653d22464f4e542d46414d494c593a20cbcecce52c53696d53756e3b20434f4c4f523a20233539353935393b2046 4f4e542d53495a453a2031347078223ea2da20d7a2b2e1cdeab3c9a3acc7ebb8f9beddcce1cabebdf8d0d0d2f8d0d0bfa8c8cfd6a4a1a33c2f7370616e3e3c2f703e , pubdate='2014-08-07 00:00:00', BeginTime='2014-07-27 00:00:00', Endtime=NULL, commend=1 whereId= -/*!*/;

16 binary files in the main library

<P><SPAN style=The FONT-FAMILY: Song body, SimSun; COLOR: #595959; FONT-Size:14px ">①</Span><SPAN style=The FONT-FAMILY: Song body, SimSun; COLOR: #595959; FONT-Size:14px ">Click "Register" in the top right corner and fill in the registration information as prompted.</Span></P><P><SPAN style=The FONT-FAMILY: Song body, SimSun; COLOR: #595959; FONT-Size:14px ">Note: The user name must be the mobile number.</Span></P><P Style="TEXT-Align:center "><SPAN style=The FONT-FAMILY: Song body, SimSun; COLOR: #595959; FONT-Size:14px "></Span></P><P Style="TEXT-Align:center "><SPAN style=The FONT-FAMILY: Song body, SimSun; COLOR: #595959; FONT-Size:14px "></Span></P><P Style="TEXT-Align:center "><SPAN style=The FONT-FAMILY: Song body, SimSun "><SPAN style=The FONT-FAMILY: Microsoft Jacob Black, Microsoft Yahei; COLOR: #595959; FONT-Size:14px "><IMG Style="width:600px; Height:313px "title=" -. PNG "Border="0"Hspace="0"Src="http://203.195.202.75:8080/Cm/Js/Ueditor1_3_5/Jsp/Ueditorimgs/20140807/9411407377615508. PNG "width=" -"Height="313"/></Span>&nbsp</Span></P><P><SPAN style=The FONT-FAMILY: Song body, SimSun; COLOR: #595959; FONT-Size:14px ">② registration is completed, please follow the instructions for bank card certification.</Span></P>

In the above two examples, the content in Binlog is the 16 binary number corresponding to the UTF8 encoding of the actual content of the main library.

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.