Count DML statements in MySQL binlog

Source: Internet
Author: User

Count DML statements in MySQL binlog

MASTER @ root @ test 07:44:52> create table tab02 (id int (10) primary key, name varchar (20 ));
Query OK, 0 rows affected (0.10 sec)

MASTER @ root @ test 08:34:54>
MASTER @ root @ test 08:34:54>
MASTER @ root @ test 08:34:54> insert into tab02 values (1, 'ddd ');
Query OK, 1 row affected (0.00 sec)

MASTER @ root @ test 08:34:59> insert into tab02 values (2, 'ddd ');
Query OK, 1 row affected (0.00 sec)

MASTER @ root @ test 08:35:01> insert into tab02 values (3, 'ddd ');
Query OK, 1 row affected (0.00 sec)

MASTER @ root @ test 08:35:03> insert into tab02 values (4, 'ddd ');
Query OK, 1 row affected (0.00 sec)

MASTER @ root @ test 08:35:04> insert into tab02 values (5, 'ddd ');
Query OK, 1 row affected (0.01 sec)

MASTER @ root @ test 08:35:07> insert into tab02 values (6, 'ddd ');
Query OK, 1 row affected (0.00 sec)

MASTER @ root @ test 08:35:09> delete from tab02 where id = 6;
Query OK, 1 row affected (0.02 sec)

MASTER @ root @ test 08:35:19> update tab02 set name = 'cd' where id = 1
->;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MASTER @ root @ test 08:35:39> update tab02 set name = 'cd' where id = 3;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0

 

[Root @ mynode1 mysql] #/service/mysql/bin/mysqlbinlog binlog-master.000006 | \
> Grep-I-e "^ update"-e "^ insert"-e "^ delete"-e "^ replace"-e "^ alter" | \
> Cut-c1-100 | tr' [A-Z] ''[a-z] '| \
> Sed-e "s/\ t/g; s/\ '/g; s /(. * $ //; s/set. * $ //; s/. * $ // "| sed-e" s/where. * $ // "| \
> Sort | uniq-c | sort-nr
7 insert into tab02 values
2 update tab02
1 delete from tab02

MySQL DML operation suggestions

Common MySQL DDL, DML, and DCL languages (example)

Clear binlog logs in MySQL

Related Article

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.