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
etid
Int (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: