mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> use test;

Database changed

mysql>

mysql> show tables;

+----------------+

| Tables_in_test |

+----------------+

| t1             |

+----------------+

1 row in set (0.00 sec)

mysql> show table status;

+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+

| Name | Engine | Version | Row_format | Rows | Avg_row_length | Data_length | Max_data_length | Index_length | Data_free | Auto_increment | Create_time         | Update_time | Check_time | Collation         | Checksum | Create_options | Comment |

+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+

| t1   | InnoDB |      10 | Compact    |    1 |          16384 |       16384 |               0 |            0 |         0 |           NULL | 2017-03-24 14:38:15 | NULL        | NULL       | latin1_swedish_ci |     NULL |                |         |

+------+--------+---------+------------+------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+-------------+------------+-------------------+----------+----------------+---------+

1 row in set (0.00 sec)

mysql> show table status \G

*************************** 1. row ***************************

Name: t1

Engine: InnoDB

Version: 10

Row_format: Compact

Rows: 1

Avg_row_length: 16384

Data_length: 16384

Max_data_length: 0

Index_length: 0

Data_free: 0

Auto_increment: NULL

Create_time: 2017-03-24 14:38:15

Update_time: NULL

Check_time: NULL

Collation: latin1_swedish_ci

Checksum: NULL

Create_options:

Comment:

1 row in set (0.00 sec)

mysql> select * from t1;

+------+--------+

| Id   | Name   |

+------+--------+

|    2 | cherry |

|    1 | jason  |

+------+--------+

2 rows in set (0.00 sec)

mysql> show binary logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000001 |       143 |

| mysql-bin.000002 |       583 |

+------------------+-----------+

2 rows in set (0.00 sec)

mysql> reset master;

Query OK, 0 rows affected (0.07 sec)

mysql> show binary logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000001 |       |

+------------------+-----------+

1 row in set (0.00 sec)

mysql> exit

Bye

 [mysql@mysql ~]$ mysqldump -uroot -p --skip-opt --quick --extended-insert=false --single-transaction --master-data=2 --databases test >./test_db.sql

Enter password:

[mysql@mysql ~]$ ls -ltr

total 4

-rw-rw-r--. 1 mysql mysql 1520 Mar 27 15:33 test_db.sql

[mysql@mysql ~]$ more test_db.sql

-- MySQL dump 10.13  Distrib 5.6.34, for Linux (x86_64)

--

-- Host: localhost    Database: test

-- ------------------------------------------------------

-- Server version       5.6.34-log

/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;

/*!40103 SET TIME_ZONE='+00:00' */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CH

ECKS=0 */;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' *

/;

/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--

-- Position to start replication or point-in-time recovery from

--

-- CHANGE MASTER TO MASTER_LOG_FILE=';

--

-- Current Database: `test`

--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTE

R SET latin1 */;

USE `test`;

--

-- Table structure for table `t1`

--

/*!40101 SET @saved_cs_client     = @@character_set_client */;

/*!40101 SET character_set_client = utf8 */;

CREATE TABLE `t1` (

`Id` int(11) DEFAULT NULL,

`Name` varchar(20) DEFAULT NULL

);

/*!40101 SET character_set_client = @saved_cs_client */;

--

-- Dumping data for table `t1`

--

INSERT INTO `t1` VALUES (2,'cherry');

INSERT INTO `t1` VALUES (1,'jason');

/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2017-03-27 15:33:06

[mysql@mysql ~]$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.6.34-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> insert into t1 values(3,'jerry');

ERROR 1046 (3D000): No database selected

mysql> use test;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> insert into t1 values(3,'jerry');

Query OK, 1 row affected (0.02 sec)

mysql> insert into t1 values(4,'jack');

Query OK, 1 row affected (0.07 sec)

mysql> commit;

Query OK, 0 rows affected (0.00 sec)

mysql>

mysql>

mysql>

mysql> select * frmo t1;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'frmo t1' at line 1

mysql> use test;

Database changed

mysql> select * from t1;

+------+--------+

| Id   | Name   |

+------+--------+

|    2 | cherry |

|    1 | jason  |

|    3 | jerry  |

|    4 | jack   |

+------+--------+

4 rows in set (0.00 sec)

mysql> drop table t1;

Query OK, 0 rows affected (0.09 sec)

mysql> select * from t1;

ERROR 1146 (42S02): Table 'test.t1' doesn't exist

mysql> show binary logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000001 |       666 |

+------------------+-----------+

1 row in set (0.00 sec)

mysql> flush logs;

Query OK, 0 rows affected (0.08 sec)

mysql> show binary logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000001 |       713 |

| mysql-bin.000002 |       120 |

+------------------+-----------+

2 rows in set (0.00 sec)

mysql> ? show binlog events

Name: 'SHOW BINLOG EVENTS'

Description:

Syntax:

SHOW BINLOG EVENTS

[IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]

Shows the events in the binary log. If you do not specify 'log_name',

the first binary log is displayed.

URL: http://dev.mysql.com/doc/refman/5.6/en/show-binlog-events.html

mysql> show binlog events in 'mysql-bin.000001';

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                                  |

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

| mysql-bin.000001 |   4 | Format_desc |         1 |         120 | Server ver: 5.6.34-log, Binlog ver: 4                 |

| mysql-bin.000001 | 120 | Query       |         1 |         199 | BEGIN                                                 |

| mysql-bin.000001 | 199 | Query       |         1 |         305 | use `test`; insert into t1 values(3,'jerry')          |

| mysql-bin.000001 | 305 | Xid         |         1 |         336 | COMMIT /* xid=252 */                                  |

| mysql-bin.000001 | 336 | Query       |         1 |         415 | BEGIN                                                 |

| mysql-bin.000001 | 415 | Query       |         1 |         520 | use `test`; insert into t1 values(4,'jack')           |

| mysql-bin.000001 | 520 | Xid         |         1 |         551 | COMMIT /* xid=253 */                                  |

| mysql-bin.000001 | | Query       |         1 |         | use `test`; DROP TABLE `t1` /* generated by server */ |

| mysql-bin.000001 | 666 | Rotate      |         1 |         713 | mysql-bin.000002;pos=4                                |

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

9 rows in set (0.00 sec)

mysql> exit

Bye

[mysql@mysql ~]$ ls

test_db.sql

[mysql@mysql ~]$ more test_db.sql

-- MySQL dump 10.13  Distrib 5.6.34, for Linux (x86_64)

--

-- Host: localhost    Database: test

-- ------------------------------------------------------

-- Server version       5.6.34-log

/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;

/*!40103 SET TIME_ZONE='+00:00' */;

/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;

/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CH

ECKS=0 */;

/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' *

/;

/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--

-- Position to start replication or point-in-time recovery from

--

-- CHANGE MASTER TO MASTER_LOG_FILE=;

--

-- Current Database: `test`

--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTE

R SET latin1 */;

USE `test`;

--

-- Table structure for table `t1`

--

/*!40101 SET @saved_cs_client     = @@character_set_client */;

/*!40101 SET character_set_client = utf8 */;

CREATE TABLE `t1` (

`Id` int(11) DEFAULT NULL,

`Name` varchar(20) DEFAULT NULL

);

/*!40101 SET character_set_client = @saved_cs_client */;

--

-- Dumping data for table `t1`

--

INSERT INTO `t1` VALUES (2,'cherry');

INSERT INTO `t1` VALUES (1,'jason');

/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;

/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;

/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2017-03-27 15:33:06

[mysql@mysql ~]$ grep CHANGE MASTER test_db.sql

grep: MASTER: No such file or directory

test_db.sql:-- CHANGE MASTER TO MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=120;

[mysql@mysql ~]$ grep "CHANGE MASTER" test_db.sql

-- CHANGE MASTER TO MASTER_LOG_FILE=';

 [mysql@mysql ~]$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 7

Server version: 5.6.34-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> drop database test;

Query OK, 0 rows affected (0.00 sec)

mysql> exit

Bye

[mysql@mysql ~]$ mysql < ./test_db.sql

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

[mysql@mysql ~]$ mysql -uroot -p < ./test_db.sql

Enter password:

[mysql@mysql ~]$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 11

Server version: 5.6.34-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| test               |

+--------------------+

4 rows in set (0.00 sec)

mysql> use test;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql>

mysql> select * from t1;  

+------+--------+

| Id   | Name   |

+------+--------+

|    2 | cherry |

|    1 | jason  |

+------+--------+

2 rows in set (0.00 sec)

mysql> show binary logs;

+------------------+-----------+

| Log_name         | File_size |

+------------------+-----------+

| mysql-bin.000001 |       713 |

| mysql-bin.000002 |       964 |

+------------------+-----------+

2 rows in set (0.00 sec)

mysql> show binlog events in 'mysql-bin.000002';

+------------------+-----+-------------+-----------+-------------+--------------------------------------------------------------------------------------------------+

| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                                                                             |

+------------------+-----+-------------+-----------+-------------+--------------------------------------------------------------------------------------------------+

| mysql-bin.000002 |   4 | Format_desc |         1 |         120 | Server ver: 5.6.34-log, Binlog ver: 4                                                            |

| mysql-bin.000002 | 120 | Query       |         1 |         205 | drop database test                                                                               |

| mysql-bin.000002 | 205 | Query       |         1 |         367 | CREATE DATABASE /*!32312 IF NOT EXISTS*/ `test` /*!40100 DEFAULT CHARACTER SET latin1 */         |

| mysql-bin.000002 | 367 | Query       |         1 |         525 | use `test`; CREATE TABLE `t1` (

`Id` int(11) DEFAULT NULL,

`Name` varchar(20) DEFAULT NULL

) |

| mysql-bin.000002 | 525 | Query       |         1 |         604 | BEGIN                                                                                            |

| mysql-bin.000002 | 604 | Query       |         1 |         714 | use `test`; INSERT INTO `t1` VALUES (2,'cherry')                                                 |

| mysql-bin.000002 | 714 | Xid         |         1 |         745 | COMMIT /* xid=284 */                                                                             |

| mysql-bin.000002 | 745 | Query       |         1 |         824 | BEGIN                                                                                            |

| mysql-bin.000002 | 824 | Query       |         1 |         933 | use `test`; INSERT INTO `t1` VALUES (1,'jason')                                                  |

| mysql-bin.000002 | 933 | Xid         |         1 |         964 | COMMIT /* xid=285 */                                                                             |

+------------------+-----+-------------+-----------+-------------+--------------------------------------------------------------------------------------------------+

10 rows in set (0.00 sec)

mysql> show binlog events in 'mysql-bin.000001';

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                                  |

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

| mysql-bin.000001 |   4 | Format_desc |         1 |         120 | Server ver: 5.6.34-log, Binlog ver: 4                 |

| mysql-bin.000001 | 120 | Query       |         1 |         199 | BEGIN                                                 |

| mysql-bin.000001 | 199 | Query       |         1 |         305 | use `test`; insert into t1 values(3,'jerry')          |

| mysql-bin.000001 | 305 | Xid         |         1 |         336 | COMMIT /* xid=252 */                                  |

| mysql-bin.000001 | 336 | Query       |         1 |         415 | BEGIN                                                 |

| mysql-bin.000001 | 415 | Query       |         1 |         520 | use `test`; insert into t1 values(4,'jack')           |

| mysql-bin.000001 | 520 | Xid         |         1 |         551 | COMMIT /* xid=253 */                                  |

| mysql-bin.000001 | 551 | Query       |         1 |         666 | use `test`; DROP TABLE `t1` /* generated by server */ |

| mysql-bin.000001 | 666 | Rotate      |         1 |         713 | mysql-bin.000002;pos=4                                |

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

9 rows in set (0.00 sec)

[mysql@mysql ~]$ cd /mysql/data/

[mysql@mysql data]$ ls

auto.cnf  ib_logfile0  mysql             mysql-bin.000002  mysql.err  performance_schema

ibdata1   ib_logfile1  mysql-bin.000001  mysql-bin.index   mysql.pid  test

[mysql@mysql data]$ ls -ltr

total 110656

-rw-rw----. 1 mysql mysql 50331648 Mar 24 10:57 ib_logfile1

drwx------. 2 mysql mysql     4096 Mar 24 10:57 performance_schema

drwx------. 2 mysql mysql     4096 Mar 24 10:57 mysql

-rw-rw----. 1 mysql mysql       56 Mar 24 11:01 auto.cnf

-rw-rw----. 1 mysql mysql        6 Mar 24 15:15 mysql.pid

-rw-r-----. 1 mysql mysql    25605 Mar 24 15:15 mysql.err

-rw-rw----. 1 mysql mysql      713 Mar 27 15:36 mysql-bin.000001

-rw-rw----. 1 mysql mysql       38 Mar 27 15:36 mysql-bin.index

drwx------. 2 mysql mysql     4096 Mar 27 15:53 test

-rw-rw----. 1 mysql mysql      964 Mar 27 15:53 mysql-bin.000002

-rw-rw----. 1 mysql mysql 12582912 Mar 27 15:53 ibdata1

-rw-rw----. 1 mysql mysql 50331648 Mar 27 15:53 ib_logfile0

[mysql@mysql data]$ mysqlbinlog --help

mysqlbinlog Ver 3.4 for Linux at x86_64

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Dumps a MySQL binary log in a format usable for viewing or for piping to

the mysql command line client.

Usage: mysqlbinlog [options] log-files

-?, --help          Display this help and exit.

--base64-output=name

Determine when the output statements should be

base64-encoded BINLOG statements: 'never' disables it and

works only for binlogs without row-based events;

'decode-rows' decodes row events into commented

pseudo-SQL statements if the --verbose option is also

given; 'auto' prints base64 only when necessary (i.e.,

for row-based events and format description events).  If

no --base64-output[=name] option is given at all, the

default is 'auto'.

--bind-address=name IP address to bind to.

--character-sets-dir=name

Directory for character set files.

-d, --database=name List entries for just this database (local log only).

--debug-check       Check memory and open file usage at exit .

--debug-info        Print some debug info at exit.

--default-auth=name Default authentication client-side plugin to use.

-D, --disable-log-bin

Disable binary log. This is useful, if you enabled

--to-last-log and are sending the output to the same

MySQL server. This way you could avoid an endless loop.

You would also like to use it when restoring after a

crash to avoid duplication of the statements you already

have. NOTE: you will need a SUPER privilege to use this

option.

-F, --force-if-open Force if binlog was not closed properly.

(Defaults to on; use --skip-force-if-open to disable.)

-f, --force-read    Force reading unknown binlog events.

-H, --hexdump       Augment output with hexadecimal and ASCII event dump.

-h, --host=name     Get the binlog from server.

-l, --local-load=name

Prepare local temporary files for LOAD DATA INFILE in the

specified directory.

-o, --offset=#      Skip the first N entries.

-p, --password[=name]

Password to connect to remote server.

--plugin-dir=name   Directory for client-side plugins.

-P, --port=#        Port number to use for connection or 0 for default to, in

order of preference, my.cnf, $MYSQL_TCP_PORT,

/etc/services, built-in default (3306).

--protocol=name     The protocol to use for connection (tcp, socket, pipe,

memory).

-R, --read-from-remote-server

Read binary logs from a MySQL server. This is an alias

for read-from-remote-master=BINLOG-DUMP-NON-GTIDS.

--read-from-remote-master=name

Read binary logs from a MySQL server through the

COM_BINLOG_DUMP or COM_BINLOG_DUMP_GTID commands by

setting the option to either BINLOG-DUMP-NON-GTIDS or

BINLOG-DUMP-GTIDS, respectively. If

--read-from-remote-master=BINLOG-DUMP-GTIDS is combined

with --exclude-gtids, transactions can be filtered out on

the master avoiding unnecessary network traffic.

--raw               Requires -R. Output raw binlog data instead of SQL

statements, output is to log files.

-r, --result-file=name

Direct output to a given file. With --raw this is a

prefix for the file names.

--secure-auth       Refuse client connecting to server if it uses old

(pre-4.1.1) protocol.

(Defaults to on; use --skip-secure-auth to disable.)

--server-id=#       Extract only binlog entries created by the server having

the given id.

--server-id-bits=#  Set number of significant bits in server-id

--set-charset=name  Add 'SET NAMES character_set' to the output.

-s, --short-form    Just show regular queries: no extra info and no row-based

events. This is for testing only, and should not be used

in production systems. If you want to suppress

base64-output, consider using --base64-output=never

instead.

-S, --socket=name   The socket file to use for connection.

--start-datetime=name

Start reading the binlog at first event having a datetime

equal or posterior to the argument; the argument must be

a date and time in the local time zone, in any format

accepted by the MySQL server for DATETIME and TIMESTAMP

types, for example: 2004-12-25 11:25:56 (you should

probably use quotes for your shell to set it properly).

-j, --start-position=#

Start reading the binlog at position N. Applies to the

first binlog passed on the command line.

--stop-datetime=name

Stop reading the binlog at first event having a datetime

equal or posterior to the argument; the argument must be

a date and time in the local time zone, in any format

accepted by the MySQL server for DATETIME and TIMESTAMP

types, for example: 2004-12-25 11:25:56 (you should

probably use quotes for your shell to set it properly).

--stop-never        Wait for more data from the server instead of stopping at

the end of the last log. Implicitly sets --to-last-log

but instead of stopping at the end of the last log it

continues to wait till the server disconnects.

--stop-never-slave-server-id=#

The slave server_id used for --read-from-remote-server

--stop-never.

--stop-position=#   Stop reading the binlog at position N. Applies to the

last binlog passed on the command line.

-t, --to-last-log   Requires -R. Will not stop at the end of the requested

binlog but rather continue printing until the end of the

last binlog of the MySQL server. If you send the output

to the same MySQL server, that may lead to an endless

loop.

-u, --user=name     Connect to the remote server as username.

-v, --verbose       Reconstruct pseudo-SQL statements out of row events. -v

-v adds comments on column data types.

-V, --version       Print version and exit.

--open-files-limit=#

Used to reserve file descriptors for use by this program.

-c, --verify-binlog-checksum

Verify checksum binlog events.

--binlog-row-event-max-size=#

The maximum size of a row-based binary log event in

bytes. Rows will be grouped into events smaller than this

size if possible. This value must be a multiple of 256.

--skip-gtids        Do not print Global Transaction Identifier information

(SET GTID_NEXT=... etc).

--include-gtids=name

Print events whose Global Transaction Identifiers were

provided.

--exclude-gtids=name

Print all events but those whose Global Transaction

Identifiers were provided.

Variables (--variable-name=value)

and boolean options {FALSE|TRUE}  Value (after reading options)

--------------------------------- ----------------------------------------

base64-output                     (No default value)

bind-address                      (No default value)

character-sets-dir                (No default value)

database                          (No default value)

debug-check                       FALSE

debug-info                        FALSE

default-auth                      (No default value)

disable-log-bin                   FALSE

force-if-open                     TRUE

force-read                        FALSE

hexdump                           FALSE

host                              (No default value)

local-load                        (No default value)

offset                            0

plugin-dir                        (No default value)

port                              0

read-from-remote-server           FALSE

read-from-remote-master           (No default value)

raw                               FALSE

result-file                       (No default value)

secure-auth                       TRUE

server-id                         0

server-id-bits                    32

set-charset                       (No default value)

short-form                        FALSE

socket                            (No default value)

start-datetime                    (No default value)

start-position                    4

stop-datetime                     (No default value)

stop-never                        FALSE

stop-never-slave-server-id        -1

stop-position                     18446744073709551615

to-last-log                       FALSE

user                              (No default value)

open-files-limit                  64

verify-binlog-checksum            FALSE

binlog-row-event-max-size         4294967040

skip-gtids                        FALSE

include-gtids                     (No default value)

exclude-gtids                     (No default value)

[mysql@mysql data]$ mysqlbinlog --start-position=120 --stop-position=551 -vv ./mysql-bin.000001

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;

/*!40019 SET @@session.max_insert_delayed_threads=0*/;

/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;

DELIMITER /*!*/;

# at 4

#170327 15:30:28 server id 1  end_log_pos 120 CRC32 0x78e1ef11  Start: binlog v 4, server v 5.6.34-log created 170327 15:30:28 at startup

ROLLBACK/*!*/;

BINLOG '

lL/YWA8BAAAAdAAAAHgAAAAAAAQANS42LjM0LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

AAAAAAAAAAAAAAAAAACUv9hYEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAARHv

4Xg=

'/*!*/;

# at 120

#170327 15:35:20 server id 1  end_log_pos 199 CRC32 0xbb9e80c7  Query   thread_id=6     exec_time=0     error_code=0

SET TIMESTAMP=1490600120/*!*/;

SET @@session.pseudo_thread_id=6/*!*/;

SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/;

SET @@session.sql_mode=1073741824/*!*/;

SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;

/*!\C utf8 *//*!*/;

SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=33/*!*/;

SET @@session.lc_time_names=0/*!*/;

SET @@session.collation_database=DEFAULT/*!*/;

BEGIN

/*!*/;

# at 199

#170327 15:35:20 server id 1  end_log_pos 305 CRC32 0x510a5b05  Query   thread_id=6     exec_time=0     error_code=0

use `test`/*!*/;

SET TIMESTAMP=1490600120/*!*/;

insert into t1 values(3,'jerry')

/*!*/;

# at 305

#170327 15:35:20 server id 1  end_log_pos 336 CRC32 0x473228cd  Xid = 252

COMMIT/*!*/;

# at 336

#170327 15:35:32 server id 1  end_log_pos 415 CRC32 0xb6ffb799  Query   thread_id=6     exec_time=0     error_code=0

SET TIMESTAMP=1490600132/*!*/;

BEGIN

/*!*/;

# at 415

#170327 15:35:32 server id 1  end_log_pos 520 CRC32 0xa6b5797a  Query   thread_id=6     exec_time=0     error_code=0

SET TIMESTAMP=1490600132/*!*/;

insert into t1 values(4,'jack')

/*!*/;

# at 520

#170327 15:35:32 server id 1  end_log_pos 551 CRC32 0x5a0db63d  Xid = 253

COMMIT/*!*/;

DELIMITER ;

# End of log file

ROLLBACK /* added by mysqlbinlog */;

/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;

/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;

[mysql@mysql data]$ mysqlbinlog --start-position=120 --stop-position=551 -vv ./mysql-bin.000001 | mysql -uroot -p

Enter password:

[mysql@mysql data]$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 15

Server version: 5.6.34-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use test;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select * from t1;

+------+--------+

| Id   | Name   |

+------+--------+

|    2 | cherry |

|    1 | jason  |

|    3 | jerry  |

|    4 | jack   |

+------+--------+

4 rows in set (0.00 sec)

mysql>

mysql> show binlog events in 'mysql-bin.000001';

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

| Log_name         | Pos | Event_type  | Server_id | End_log_pos | Info                                                  |

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

| mysql-bin.000001 |   4 | Format_desc |         1 |         120 | Server ver: 5.6.34-log, Binlog ver: 4                 |

| mysql-bin.000001 | 120 | Query       |         1 |         199 | BEGIN                                                 |

| mysql-bin.000001 | 199 | Query       |         1 |         305 | use `test`; insert into t1 values(3,'jerry')          |

| mysql-bin.000001 | 305 | Xid         |         1 |         336 | COMMIT /* xid=252 */                                  |

| mysql-bin.000001 | 336 | Query       |         1 |         415 | BEGIN                                                 |

| mysql-bin.000001 | 415 | Query       |         1 |         520 | use `test`; insert into t1 values(4,'jack')           |

| mysql-bin.000001 | 520 | Xid         |         1 |         551 | COMMIT /* xid=253 */                                  |

| mysql-bin.000001 | 551 | Query       |         1 |         | use `test`; DROP TABLE `t1` /* generated by server */ |

| mysql-bin.000001 | 666 | Rotate      |         1 |         713 | mysql-bin.000002;pos=4                                |

+------------------+-----+-------------+-----------+-------------+-------------------------------------------------------+

9 rows in set (0.00 sec)

mysql> exit

Bye

-vv ./mysql-bin.000001 | mysql -uroot -p

Enter password:

[mysql@mysql data]$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 18

Server version: 5.6.34-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use test;

Database changed

mysql> select * from t1;

ERROR 1146 (42S02): Table 'test.t1' doesn't exist

mysql>

mysqldump备份与恢复笔记的更多相关文章

  1. MySQL备份与恢复-mysqldump备份与恢复

    这片博文主要用来介绍MySQL的备份与恢复: MySQL的备份形式可以分为如下几种: 热备----即不停机备份 冷备----需要关闭MySQL,然后备份其数据文件.(停机备份一般是直接拷贝其datad ...

  2. MYSQL5.6学习——mysqldump备份与恢复

    MYSQL备份 冷备份:停止服务进行备份,即停止数据库的写入 热备份:不停止服务进行备份(在线) l  mysql的MyIsam引擎只支持冷备份,InnoDB支持热备份,原因: InnoDB引擎是事务 ...

  3. MySQL mysqldump备份与恢复

    1 用户权限 grant select,RELOAD,PROCESS,SUPER, REPLICATION CLIENT ON *.* TO 'bak'@'192.168.%' IDENTIFIED ...

  4. mysqldump使用笔记

    mysqldump备份简述 mysqldump可产生两种类型的输出文件,取决于是否选用 --tab=dir_name选项. 1.不使用 --tab=dir_name选项,mysqldump产生的数据文 ...

  5. mysqldump 备份与恢复数据库

    备份数据库 mysqldump -u root -plvtao test > /home/bak.sql 数据库还原,常用source 命令登陆 mysql -u root -p mysql&g ...

  6. mysqldump 备份与恢复操作记录

     一,参数详解 [root@bug ~]# ? mysqldump --master-data[=#] mysqldump导出数据时,当这个参数的值为1的时候,mysqldump出来的文件就会包括CH ...

  7. MySQL 数据库的备份与恢复

    一.MySQL 常见的备份方式 1. 直接拷贝数据库文件(物理拷贝) 2. 使用 mysqldump 工具备份 3. 使用 mysqlhotcopy 工具备份 4. 使用 mysql 的主从同步复制, ...

  8. Linux--MySQL 日志管理、备份与恢复

    MySQL 日志管理.备份与恢复一.MySQL 日志管理二.数据库备份的重要性与分类  1.数据备份的重要性  2.从物理与逻辑的角度,备份分为  3.从数据库的备份策略角度,备份可分为三.常见的备份 ...

  9. MySQL 日志管理及备份与恢复

    MySQL 日志管理及备份与恢复 1.日志管理 2.备份与恢复 1.日志管理: MySQL的默认日志保存位置为/usr/local/mysql/data 日志开启方式有两种:通过配置文件或者是通过命令 ...

随机推荐

  1. Linux下输入某些命令时会提示:bash:command not found

    首先,查看$PATH中是否包含了这些命令. $PATH:决定了shell到哪些目录中去寻找命令或程序,PATH值是一系列的目录.当运行程序时,linux到这些目录下搜索进行编译链接. 格式: PATH ...

  2. 拒绝服务(DoS)理解、防御与实现

    一.说明 我一直不明白为什么拒绝服务,初学着喜欢拿来装逼.媒体喜欢吹得神乎其神.公司招聘也喜欢拿来做标准,因为我觉得拒绝服务和社会工程学就是最名不副实的两样东西.当然由于自己不明确拒绝服务在代码上是怎 ...

  3. 单点登录系统实现基于SpringBoot

    今天的干货有点湿,里面夹杂着我的泪水.可能也只有代码才能让我暂时的平静.通过本章内容你将学到单点登录系统和传统登录系统的区别,单点登录系统设计思路,Spring4 Java配置方式整合HttpClie ...

  4. RAID的详细配置

    一.RAID 1.RAID机制通过使用多硬盘并行工作的方式来提高硬盘的IO性能 2.RAID分为多种,称之为RAID level,RAID共有7级:RAID0~RAID6 3.常用的RAID级别有:R ...

  5. 移动 Ubuntu16.04 桌面左侧任务栏到屏幕底部

    按下 Ctrl + Alt + t 键盘组合键调出终端,在终端中输入以下命令: gsettings set com.canonical.Unity.Launcher launcher-position ...

  6. union 和 case

    UNION 指令的目的是将两个 SQL 语句的结果合并起来,可以查看你要的查询结果. CASE更多的是一种判断分类,就想其他语言的case一样 1. CASE WHEN 表达式有两种形式 --简单Ca ...

  7. dos语法

    一)MD——建立子目录 1.功能:创建新的子目录 2.类型:内部命令 3.格式:MD[盘符:][路径名]〈子目录名〉 4.使用说明: (1)“盘符”:指定要建立子目录的磁盘驱动器字母,若省略,则为当前 ...

  8. Linux 创建虚拟机,配置网卡,桥接,连接XShell

    一.新建虚拟机 1.“root”    输入密码: 2.看虚拟机的IP地址 “ifconfig” 二.配置网卡 1.更改设置(打开vim编辑) “vim /etc/sysconfig/network- ...

  9. Python全栈之路----函数----参数

    参数可以让你的函数更灵活,不只能做死的动作,还可以根据调用时传参的不同决定函数内部的执行流程. 形参:只有在被调用时才分配内存单元,在调用结束时,即可释放所分配的内存单元.因此形参只在函数内部有效.函 ...

  10. 12.python-metaclass元类

    1.python中一切皆是对象,类本身也是一个对象,当使用关键字class的时候,python解释器在加载class的时候会创建一个对象(这里的对象指的是类而非类的实例) class Foo: #cl ...