1 [root@zlm3 09:36:57 ~/binlog2sql/binlog2sql]
  2 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000004'
  3 Traceback (most recent call last):
  4   File "binlog2sql.py", line 149, in <module>
  5     back_interval=args.back_interval, only_dml=args.only_dml, sql_type=args.sql_type)
  6   File "binlog2sql.py", line 46, in __init__
  7     self.connection = pymysql.connect(**self.conn_setting)
  8   File "/usr/lib/python2.7/site-packages/pymysql/__init__.py", line 90, in Connect
  9     return Connection(*args, **kwargs)
 10   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 706, in __init__
 11     self.connect()
 12   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 932, in connect
 13     self._request_authentication()
 14   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1152, in _request_authentication
 15     auth_packet = self._read_packet()
 16   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1014, in _read_packet
 17     packet.check_error()
 18   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error
 19     err.raise_mysql_exception(self._data)
 20   File "/usr/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
 21     raise errorclass(errno, errval)
 22 pymysql.err.OperationalError: (1045, u"Access denied for user 'root'@'zlm3' (using password: YES)")  --It seems the connection failure.
 23 
 24 [root@zlm3 09:37:32 ~/binlog2sql/binlog2sql]
 25 #mysql
 26 Welcome to the MySQL monitor.  Commands end with ; or \g.
 27 Your MySQL connection id is 15
 28 Server version: 5.7.21-log MySQL Community Server (GPL)
 29 
 30 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
 31 
 32 Oracle is a registered trademark of Oracle Corporation and/or its
 33 affiliates. Other names may be trademarks of their respective
 34 owners.
 35 
 36 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 37 
 38 (root@localhost mysql3306.sock)[(none)]09:43:33>alter user 'root'@'192.168.1.102' identified by 'Passw0rd';
 39 ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'192.168.1.102'
 40 (root@localhost mysql3306.sock)[(none)]09:44:10>create user 'root'@'192.168.1.102' identified by 'Passw0rd';
 41 Query OK, 0 rows affected (0.00 sec)
 42 
 43 (root@localhost mysql3306.sock)[(none)]09:47:37>exit
 44 Bye
 45 
 46 [root@zlm3 09:47:40 ~/binlog2sql/binlog2sql]
 47 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000004'
 48 Traceback (most recent call last):
 49   File "binlog2sql.py", line 149, in <module>
 50     back_interval=args.back_interval, only_dml=args.only_dml, sql_type=args.sql_type)
 51   File "binlog2sql.py", line 48, in __init__
 52     cursor.execute("SHOW MASTER STATUS")
 53   File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 166, in execute
 54     result = self._query(query)
 55   File "/usr/lib/python2.7/site-packages/pymysql/cursors.py", line 322, in _query
 56     conn.query(q)
 57   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 856, in query
 58     self._affected_rows = self._read_query_result(unbuffered=unbuffered)
 59   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1057, in _read_query_result
 60     result.read()
 61   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1340, in read
 62     first_packet = self.connection._read_packet()
 63   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 1014, in _read_packet
 64     packet.check_error()
 65   File "/usr/lib/python2.7/site-packages/pymysql/connections.py", line 393, in check_error
 66     err.raise_mysql_exception(self._data)
 67   File "/usr/lib/python2.7/site-packages/pymysql/err.py", line 107, in raise_mysql_exception
 68     raise errorclass(errno, errval)
 69 pymysql.err.InternalError: (1227, u'Access denied; you need (at least one of) the SUPER, REPLICATION CLIENT privilege(s) for this operation')  --The user 'root'@'192.168.1.102' is short of imperative privileges.
 70 
 71 [root@zlm3 09:47:43 ~/binlog2sql/binlog2sql]
 72 #mysql
 73 Welcome to the MySQL monitor.  Commands end with ; or \g.
 74 Your MySQL connection id is 17
 75 Server version: 5.7.21-log MySQL Community Server (GPL)
 76 
 77 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
 78 
 79 Oracle is a registered trademark of Oracle Corporation and/or its
 80 affiliates. Other names may be trademarks of their respective
 81 owners.
 82 
 83 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 84 
 85 (root@localhost mysql3306.sock)[(none)]09:49:43>grant select,replication slave,replication client on *.* to 'root'@'192.168.1.102';
 86 Query OK, 0 rows affected (0.00 sec)
 87 
 88 (root@localhost mysql3306.sock)[(none)]09:50:24>exit
 89 Bye
 90 
 91 [root@zlm3 09:50:29 ~/binlog2sql/binlog2sql]
 92 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000004'
 93 CREATE USER 'root'@'192.168.1.102' IDENTIFIED WITH 'mysql_native_password' AS '*DDFB542AA0BD1D251995D81AEBEB96DEEAD1132F';
 94 GRANT SELECT, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'root'@'192.168.1.102';
 95 
 96 [root@zlm3 09:50:32 ~/binlog2sql/binlog2sql]
 97 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000003'
 98 CREATE USER 'repl'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*872ECE72A7EBAC6A183C90D7043D5F359BD85A9E';
 99 GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';
100 USE zlm;
101 create table flash_test(
102 id int unsigned not null auto_increment,
103 code bigint unsigned not null default '0',
104 primary key(id)
105 ) engine=innodb charset utf8mb4;
106 USE zlm;
107 CREATE DEFINER=`root`@`localhost` PROCEDURE `pro_insert`(count int)
108 begin
109 declare i int unsigned default 0;
110 start transaction;
111 while i < count do
112 insert into flash_test(code) values(i);
113 set i=i+1;
114 end while;
115 commit;
116 end;
117 
118 [root@zlm3 09:51:06 ~/binlog2sql/binlog2sql]
119 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000004' --only-dml --sql-typedelete --stop-never > flashback.sql
120 usage: binlog2sql.py [-h HOST] [-u USER] [-p PASSWORD] [-P PORT]
121                      [--start-file START_FILE] [--start-position START_POS]
122                      [--stop-file END_FILE] [--stop-position END_POS]
123                      [--start-datetime START_TIME] [--stop-datetime STOP_TIME]
124                      [--stop-never] [--help] [-d [DATABASES [DATABASES ...]]]
125                      [-t [TABLES [TABLES ...]]] [--only-dml]
126                      [--sql-type [SQL_TYPE [SQL_TYPE ...]]] [-K] [-B]
127                      [--back-interval BACK_INTERVAL]
128 binlog2sql.py: error: unrecognized arguments: --sql-typedelete
129 
130 [root@zlm3 10:00:12 ~/binlog2sql/binlog2sql]
131 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000004' --only-dml --sql-type delete --stop-never > flashback.sql
132 
133 [root@zlm3 10:00:35 ~/binlog2sql/binlog2sql]
134 #cat flashback.sql
135 
136 [root@zlm3 10:00:47 ~/binlog2sql/binlog2sql]
137 #ls -l
138 total 36
139 -rwxrwxrwx 1 root root  7882 Jun  6 07:21 binlog2sql.py
140 -rwxrwxrwx 1 root root 11696 Jun  6 07:21 binlog2sql_util.py
141 -rw-r--r-- 1 root root 10344 Jun  6 09:35 binlog2sql_util.pyc
142 -rw-r--r-- 1 root root     0 Jun  6 10:00 flashback.sql
143 -rwxrwxrwx 1 root root    98 Jun  6 07:21 __init__.py
144 
145 [root@zlm3 10:00:52 ~/binlog2sql/binlog2sql]
146 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='mysql-bin.000003' --only-dml --sql-type delete --stop-never > flashback.sql
147 
148 [root@zlm3 10:01:26 ~/binlog2sql/binlog2sql]
149 #cat flashback.sql
150 
151 [root@zlm3 10:01:32 ~/binlog2sql/binlog2sql]
152 #
  1 [root@zlm1 17:10:16 ~/PyMySQL-0.8.1]
  2 #ls -l
  3 total 52
  4 -rw-r--r-- 1 501 games 8006 May  7 12:22 CHANGELOG
  5 -rw-r--r-- 1 501 games  320 May 18  2016 example.py
  6 -rw-r--r-- 1 501 games 1070 Nov 27  2013 LICENSE
  7 -rw-r--r-- 1 501 games   84 Jan 14  2015 MANIFEST.in
  8 -rw-r--r-- 1 501 games 6051 May  7 12:27 PKG-INFO
  9 drwxr-xr-x 4 501 games 4096 May  7 12:27 pymysql
 10 drwxr-xr-x 2 501 games  101 May  7 12:27 PyMySQL.egg-info
 11 -rw-r--r-- 1 501 games 3879 May  7 12:10 README.rst
 12 -rwxr-xr-x 1 501 games  704 Aug 29  2016 runtests.py
 13 -rw-r--r-- 1 501 games  145 May  7 12:27 setup.cfg
 14 -rwxr-xr-x 1 501 games 1491 May  7 12:26 setup.py
 15 -rw-r--r-- 1 501 games  184 Jan 13  2017 tox.ini
 16 
 17 [root@zlm1 17:10:17 ~/PyMySQL-0.8.1]
 18 #python setup.py install
 19 Traceback (most recent call last):
 20   File "setup.py", line 3, in <module>
 21     from setuptools import setup, find_packages
 22 ImportError: No module named setuptools
 23 
 24 [root@zlm1 17:10:32 ~/PyMySQL-0.8.1]
 25 #chown root.root -R *
 26 
 27 [root@zlm1 17:11:23 ~/PyMySQL-0.8.1]
 28 #ls -l
 29 total 52
 30 -rw-r--r-- 1 root root 8006 May  7 12:22 CHANGELOG
 31 -rw-r--r-- 1 root root  320 May 18  2016 example.py
 32 -rw-r--r-- 1 root root 1070 Nov 27  2013 LICENSE
 33 -rw-r--r-- 1 root root   84 Jan 14  2015 MANIFEST.in
 34 -rw-r--r-- 1 root root 6051 May  7 12:27 PKG-INFO
 35 drwxr-xr-x 4 root root 4096 May  7 12:27 pymysql
 36 drwxr-xr-x 2 root root  101 May  7 12:27 PyMySQL.egg-info
 37 -rw-r--r-- 1 root root 3879 May  7 12:10 README.rst
 38 -rwxr-xr-x 1 root root  704 Aug 29  2016 runtests.py
 39 -rw-r--r-- 1 root root  145 May  7 12:27 setup.cfg
 40 -rwxr-xr-x 1 root root 1491 May  7 12:26 setup.py
 41 -rw-r--r-- 1 root root  184 Jan 13  2017 tox.ini
 42 
 43 [root@zlm1 17:11:25 ~/PyMySQL-0.8.1]
 44 #python setup.py install
 45 Traceback (most recent call last):
 46   File "setup.py", line 3, in <module>
 47     from setuptools import setup, find_packages
 48 ImportError: No module named setuptools  -- It seems another module name "setuptools" is needed.
 49 
 50 [root@zlm1 17:22:25 ~/setuptools-39.2.0]
 51 #ls -l
 52 total 192
 53 -rwxrwxrwx 1 root root   1669 May 19 13:18 bootstrap.py
 54 -rwxrwxrwx 1 root root 113612 May 19 13:18 CHANGES.rst
 55 -rwxrwxrwx 1 root root    223 May 19 13:18 conftest.py
 56 drwxrwxrwx 4 root root   4096 Jun  8 17:18 docs
 57 -rwxrwxrwx 1 root root    126 May 19 13:18 easy_install.py
 58 -rwxrwxrwx 1 root root  10317 May 19 13:18 launcher.c
 59 -rwxrwxrwx 1 root root   1078 May 19 13:18 LICENSE
 60 -rwxrwxrwx 1 root root    430 May 19 13:18 MANIFEST.in
 61 -rwxrwxrwx 1 root root   1640 May 19 13:18 msvc-build-launcher.cmd
 62 -rwxrwxrwx 1 root root   1438 May 19 13:18 pavement.py
 63 -rwxrwxrwx 1 root root   3160 May 19 13:19 PKG-INFO
 64 drwxrwxrwx 5 root root    103 Jun  8 17:18 pkg_resources
 65 -rwxrwxrwx 1 root root    493 May 19 13:18 pytest.ini
 66 -rwxrwxrwx 1 root root   1545 May 19 13:18 README.rst
 67 -rwxrwxrwx 1 root root    434 May 19 13:19 setup.cfg
 68 -rwxrwxrwx 1 root root   7365 May 19 13:18 setup.py
 69 drwxrwxrwx 6 root root   4096 Jun  8 17:18 setuptools
 70 drwxrwxrwx 2 root root    143 Jun  8 17:18 setuptools.egg-info
 71 drwxrwxrwx 2 root root     46 Jun  8 17:18 tests
 72 -rwxrwxrwx 1 root root    662 May 19 13:18 towncrier_template.rst
 73 -rwxrwxrwx 1 root root   1391 May 19 13:18 tox.ini
 74 
 75 [root@zlm1 17:22:26 ~/setuptools-39.2.0]
 76 #python setup.py install
 77 running install
 78 running bdist_egg
 79 running egg_info
 80 writing requirements to setuptools.egg-info/requires.txt
 81 writing setuptools.egg-info/PKG-INFO
 82 writing top-level names to setuptools.egg-info/top_level.txt
 83 writing dependency_links to setuptools.egg-info/dependency_links.txt
 84 writing entry points to setuptools.egg-info/entry_points.txt
 85 reading manifest file 'setuptools.egg-info/SOURCES.txt'
 86 reading manifest template 'MANIFEST.in'
 87 writing manifest file 'setuptools.egg-info/SOURCES.txt'
 88 installing library code to build/bdist.linux-x86_64/egg
 89 running install_lib
 90 running build_py
 91 creating build
 92 creating build/lib
 93 ... -- Omitted.
 94  
 95 root@zlm1 17:25:21 ~/PyMySQL-0.8.1]
 96 #python setup.py install
 97 /usr/lib64/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'project_urls'
 98   warnings.warn(msg)
 99 running install
100 running bdist_egg
101 running egg_info
102 writing PyMySQL.egg-info/PKG-INFO
103 writing top-level names to PyMySQL.egg-info/top_level.txt
104 writing dependency_links to PyMySQL.egg-info/dependency_links.txt
105 reading manifest file 'PyMySQL.egg-info/SOURCES.txt'
106 reading manifest template 'MANIFEST.in'
107 writing manifest file 'PyMySQL.egg-info/SOURCES.txt'
108 installing library code to build/bdist.linux-x86_64/egg
109 running install_lib
110 running build_py
111 creating build
112 creating build/lib
113 creating build/lib/pymysql
114 ... -- Omitted.
115  
116 --Finally the PyMySQL was installed successfully.

   
secondly,”pip” command need to be installed,which can be downloaded on
the official

 

  • ***binlog2sql is coded by python,in order to use it you need to
    install python and relevant packages.


  • ***some parameter such as “binlog_format=row”,”binlog_row_image=full” etc. in MySQL
    Server should be satisfied with.


  • ***some privileges such as “super”/”replication client”,”replication slave” etc. in MySQL
    Server should be satisfied with too.


  • it seems more inconvenient rather than the MyFlash tool does.

 

 

    since we’ve got the sql file which can
flashback our lost data,let’s have a try:

 

    today,i’ll have a test with the open
source tool mysqlbinlog_flashback which is released by 58daojia,here’s
the github address:  **this tool is
similar with the binlog2sql which is also coded by python.let’s download
and unzip the tool:

 1 (root@localhost mysql3306.sock)[zlm]09:27:16>create table flash_test(
 2     -> id int unsigned not null auto_increment,
 3     -> code bigint unsigned not null default '0',
 4     -> primary key(id)
 5     -> ) engine=innodb charset utf8mb4;
 6 Query OK, 0 rows affected (0.02 sec)
 7 
 8 (root@localhost mysql3306.sock)[zlm]09:27:26>delimiter $$
 9 (root@localhost mysql3306.sock)[zlm]09:27:41>create procedure pro_insert (count int)
10     -> begin
11     -> declare i int unsigned default 0;
12     -> start transaction;
13     -> while i < count do
14     -> insert into flash_test(code) values(i);
15     -> set i=i+1;
16     -> end while;
17     -> commit;
18     -> end;
19     -> $$
20 Query OK, 0 rows affected (0.00 sec)
21 
22 (root@localhost mysql3306.sock)[zlm]09:27:41>delimiter ;
23 (root@localhost mysql3306.sock)[zlm]09:27:42>call pro_insert(10000);
24 Query OK, 0 rows affected (0.33 sec)
25 
26 (root@localhost mysql3306.sock)[zlm]09:27:55>select count(*) from flash_test;
27 +----------+
28 | count(*) |
29 +----------+
30 |    10000 |
31 +----------+
32 1 row in set (0.01 sec)
33 
34 (root@localhost mysql3306.sock)[zlm]09:28:43>select * from flash_test limit 5;
35 +----+------+
36 | id | code |
37 +----+------+
38 |  1 |    0 |
39 |  2 |    1 |
40 |  3 |    2 |
41 |  4 |    3 |
42 |  5 |    4 |
43 +----+------+
44 5 rows in set (0.00 sec)
45 
46 (root@localhost mysql3306.sock)[zlm]09:28:50>
1 [root@zlm1 16:59:16 ~/pip-10.0.1]
2 #pip install pymysql
3 Traceback (most recent call last):
4   File "/usr/bin/pip", line 5, in <module>
5     from pkg_resources import load_entry_point
6 ImportError: No module named pkg_resources
7 
8 [root@zlm1 16:59:33 ~/pip-10.0.1]
9 #
 1 [root@zlm3 10:32:40 ~/binlog2sql/binlog2sql]
 2 #python binlog2sql.py -h192.168.1.102 -P3306 -uroot -pPassw0rd -dzlm -tflash_table --start-file='/data/mysql/mysql3306/logs/mysql-bin.000004' --only-dml --sql-type delete --stop-never > flashback3.sql
 3 Traceback (most recent call last):
 4   File "binlog2sql.py", line 149, in <module>
 5     back_interval=args.back_interval, only_dml=args.only_dml, sql_type=args.sql_type)
 6   File "binlog2sql.py", line 53, in __init__
 7     raise ValueError('parameter error: start_file %s not in mysql server' % self.start_file)
 8 ValueError: parameter error: start_file /data/mysql/mysql3306/logs/mysql-bin.000004 not in mysql server
 9 
10 [root@zlm3 10:32:54 ~/binlog2sql/binlog2sql]
11 #ls -l /data/mysql/mysql3306/logs/mysql-bin.000004
12 -rw-r----- 1 mysql mysql 131467 Jun  6 09:50 /data/mysql/mysql3306/logs/mysql-bin.000004  --The binlog file is right there,it shows that it's no need to specify the absolute path in parameter "--start-file"
13 
14 [root@zlm3 10:34:07 ~/binlog2sql/binlog2sql]
15 #

 

 

 

    then,use the “pip” command to install
necessary python package below:

 

    according to the readme.md
doc,using “git” command to download it at the beginning:

 

    what’s amazing is that there’re no
delete operation found in the existent binlog files at all,how can that
happen?let’s use the original tool of MySQL itself’s to see the
details:

 

 

Summary:

  then,pretend to delete all the records
in the table “flash_table” by accidentally:

 

  
it’s the right time using the binlog2sql to flashback the missing
data:

 

 

    finally,the lost data come back
again,all the column of “name” of the 100000 rows have been changed from
“zlm” to “aaron8219”,the test finished successfully.

 1 [root@zlm3 08:54:58 /root/binlog2sql]
 2 #pwd
 3 /vagrant/binlog2sql
 4 
 5 [root@zlm3 08:56:00 /root/binlog2sql]
 6 #ls -l
 7 total 52
 8 drwxrwxrwx 2 root root    69 Jun  6 07:21 binlog2sql
 9 drwxrwxrwx 2 root root    53 Jun  6 07:21 example
10 -rwxrwxrwx 1 root root 35815 Jun  6 07:21 LICENSE
11 -rwxrwxrwx 1 root root  9749 Jun  6 07:21 README.md
12 -rwxrwxrwx 1 root root    57 Jun  6 07:21 requirements.txt
13 drwxrwxrwx 2 root root    36 Jun  6 07:21 tests
14 
15 [root@zlm3 08:56:20 /root/binlog2sql]
16 #cat requirements.txt 
17 PyMySQL==0.7.11
18 wheel==0.29.0
19 mysql-replication==0.13
20 
21 [root@zlm3 08:57:05 /root/binlog2sql]
22 #pip install -r requirements.txt
23 Collecting PyMySQL==0.7.11 (from -r requirements.txt (line 1))
24   Downloading https://files.pythonhosted.org/packages/c6/42/c54c280d8418039bd2f61284f99cb6d9e0eae80383fc72ceb6eac67855fe/PyMySQL-0.7.11-py2.py3-none-any.whl (78kB)
25     100% |?..?..?..?..?..?..?..?..?..?..?..?..?..?..?..?..| 81kB 145kB/s 
26 Collecting wheel==0.29.0 (from -r requirements.txt (line 2))
27   Downloading https://files.pythonhosted.org/packages/8a/e9/8468cd68b582b06ef554be0b96b59f59779627131aad48f8a5bce4b13450/wheel-0.29.0-py2.py3-none-any.whl (66kB)
28     100% |?..?..?..?..?..?..?..?..?..?..?..?..?..?..?..?..| 71kB 356kB/s 
29 Collecting mysql-replication==0.13 (from -r requirements.txt (line 3))
30   Downloading https://files.pythonhosted.org/packages/dd/23/384047702e694139e9fe75a8ba7ad007e8942fd119ebadabc32ce19f70f2/mysql-replication-0.13.tar.gz
31 Installing collected packages: PyMySQL, wheel, mysql-replication
32   Running setup.py install for mysql-replication ... done
33 Successfully installed PyMySQL-0.7.11 mysql-replication-0.13 wheel-0.29.0
34 
35 [root@zlm3 08:56:20 /root/binlog2sql]
36 #

    okay,now the tool
mysqlbinlog_flashback can te used normally,let’s begin our data-loss
flashback test:

 1 (root@localhost mysql3306.sock)[zlm]09:28:50>show binary logs;
 2 +------------------+-----------+
 3 | Log_name         | File_size |
 4 +------------------+-----------+
 5 | mysql-bin.000001 |       177 |
 6 | mysql-bin.000002 |       177 |
 7 | mysql-bin.000003 |   1012934 |
 8 +------------------+-----------+
 9 3 rows in set (0.00 sec)
10 
11 (root@localhost mysql3306.sock)[zlm]09:30:07>flush logs;
12 Query OK, 0 rows affected (0.02 sec)
13 
14 (root@localhost mysql3306.sock)[zlm]09:30:21>delete from flash_test;
15 Query OK, 10000 rows affected (0.05 sec)
16 
17 (root@localhost mysql3306.sock)[zlm]09:30:39>select count(*) from flash_test;
18 +----------+
19 | count(*) |
20 +----------+
21 |        0 |
22 +----------+
23 1 row in set (0.00 sec)
24 
25 (root@localhost mysql3306.sock)[zlm]09:30:47>show binary logs;
26 +------------------+-----------+
27 | Log_name         | File_size |
28 +------------------+-----------+
29 | mysql-bin.000001 |       177 |
30 | mysql-bin.000002 |       177 |
31 | mysql-bin.000003 |   1012981 |
32 | mysql-bin.000004 |    130974 |
33 +------------------+-----------+
34 4 rows in set (0.00 sec)
35 
36 (root@localhost mysql3306.sock)[zlm]09:31:33>

 

website:

 it still appear the identical
issue,what’s wrong?once more i check the readme.md it says besides the
python version,”pymysql” module is also necessary.

 

 

  the binlog2sql tool has been
installed,let’s begin the test now:

 1 [root@zlm1 17:52:12 /data/mysql/mysql3306/logs]
 2 #mysqlbinlog -vv --base64-output=decode-rows mysql-bin.000037 | sed -n '1,50p'
 3 /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
 4 /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
 5 DELIMITER /*!*/;
 6 # at 4
 7 #180608 17:42:03 server id 1003306  end_log_pos 123 CRC32 0xf0e90436     Start: binlog v 4, server v 5.7.21-log created 180608 17:42:03
 8 # Warning: this binlog is either in use or was not closed properly.
 9 # at 123
10 #180608 17:42:03 server id 1003306  end_log_pos 194 CRC32 0xb6bac207     Previous-GTIDs
11 # 2a4b3562-2ab6-11e8-be7a-080027de0e0e:5-2600051
12 # at 194
13 #180608 17:42:36 server id 1003306  end_log_pos 259 CRC32 0x67866ae9     GTID    last_committed=0    sequence_number=1    rbr_only=yes
14 /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/;
15 SET @@SESSION.GTID_NEXT= '2a4b3562-2ab6-11e8-be7a-080027de0e0e:2600052'/*!*/;
16 # at 259
17 #180608 17:42:36 server id 1003306  end_log_pos 330 CRC32 0xd92b1815     Query    thread_id=3    exec_time=0    error_code=0
18 SET TIMESTAMP=1528472556/*!*/;
19 SET @@session.pseudo_thread_id=3/*!*/;
20 SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;
21 SET @@session.sql_mode=1436549152/*!*/;
22 SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
23 /*!\C utf8 *//*!*/;
24 SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;
25 SET @@session.lc_time_names=0/*!*/;
26 SET @@session.collation_database=DEFAULT/*!*/;
27 BEGIN
28 /*!*/;
29 # at 330
30 #180608 17:42:36 server id 1003306  end_log_pos 379 CRC32 0xcfa8815d     Table_map: `zlm`.`test` mapped to number 113  -- The Table_map event from position 330.
31 # at 379
32 #180608 17:42:36 server id 1003306  end_log_pos 8575 CRC32 0xadcde7b6     Update_rows: table id 113  -- The Update_rows event from postion 379.
33 # at 8575
34 #180608 17:42:36 server id 1003306  end_log_pos 16771 CRC32 0xee29017d     Update_rows: table id 113
35 # at 16771
36 #180608 17:42:36 server id 1003306  end_log_pos 24967 CRC32 0x6306a3c2     Update_rows: table id 113
37 # at 24967
38 #180608 17:42:36 server id 1003306  end_log_pos 33163 CRC32 0x69ca971f     Update_rows: table id 113
39 # at 33163
40 #180608 17:42:36 server id 1003306  end_log_pos 41359 CRC32 0xb99e0b43     Update_rows: table id 113
41 # at 41359
42 #180608 17:42:36 server id 1003306  end_log_pos 49555 CRC32 0xe8438e0a     Update_rows: table id 113
43 # at 49555
44 #180608 17:42:36 server id 1003306  end_log_pos 57751 CRC32 0x2a83a31d     Update_rows: table id 113
45 # at 57751
46 #180608 17:42:36 server id 1003306  end_log_pos 65947 CRC32 0xbcb85d9c     Update_rows: table id 113
47 # at 65947
48 #180608 17:42:36 server id 1003306  end_log_pos 74143 CRC32 0xfd385e6b     Update_rows: table id 113
49 # at 74143
50 #180608 17:42:36 server id 1003306  end_log_pos 82339 CRC32 0x5dd0ec46     Update_rows: table id 113
51 # at 82339
52 #180608 17:42:36 server id 1003306  end_log_pos 90535 CRC32 0x14c028cb     Update_rows: table id 113
53 -- Omitted

 

 

永利皇宫登录网址 , 

   

网站地图xml地图