Encoding problems in mysql-MySQL binary log usage

Source: Internet
Author: User
The following is the binary log data of MySQL. Problem 1: log *! Cbinary **! *; And *! Cutf8 **! *; What is the role? Usage scenario: parse binary logs, store them in the database, and retrieve them and execute them to another database. Problem 2: garbled characters may occur during SQL storage, such as altertable 'lezhi _ app '. 'tmp 'change' etid' 'etid' int (11) NOTNULLcomment & #39; No. & #39; the "number" is garbled, when SQL is retrieved and executed, an error log mysql is returned.

The following is the binary log data of MySQL.
Question 1: log /*! \ C binary//! */; And /*! \ C utf8//! */; What is the role?

Use cases:
Parses binary logs and stores them in the database.
And execute it to another database.

Question 2:
Garbled characters appear when storing SQL statements, such
Alter tablelezhi_app.tmp
Changeetid etidInt (11) not null comment 'number'
The "number" is garbled, and an error is reported when the SQL is retrieved and executed? (Set names gbk is used by default in the database, and garbled characters are used if set names is not used)

Solution:
Resolution /*! \ C utf8//! */, And set names utf8 can be stored and executed normally.

Question 2:
Many SQL statements are in /*! \ C binary//! */; Below
After the set names binary program is executed, garbled characters (???) occur in some Chinese SQL statements ???).
(We use GBK for data encoding)

COMMIT /*! */; # At 87931309 #150108 20:08:13 server id 5 end_log_pos 87931465 Query thread_id = 2649685 exec_time = 0 error_code = 0use 'lezhi _ app '/*! */; Set timestamp = 1420718893 /*! */;/*! \ C utf8 *//*! */; SET @ session. character_set_client = 33, @ session. collation_connection = 33, @ session. collation_server = 8 /*! */; Alter table 'lezhi _ app'. 'tmp 'change 'etid' int (11) not null comment' no '/*! */; # At 87931465 #150108 20:08:13 server id 5 end_log_pos 87931529 Query thread_id = 2649874 exec_time = 0 error_code = 0 set timestamp = 1420718893 /*! */;/*! \ C binary *//*! */; SET @ session. character_set_client = 63, @ session. collation_connection = 28, @ session. collation_server = 8 /*! */; BEGIN /*! */; # At 87931529

The database code is as follows:

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.