【MySQL】深入理解mysqldump过程

前言:相信大家对mysqldump应该不陌生,但是大家对mysqldump的原理及备份过程真的熟悉吗?今天,我们一起来深入理解一下mysqldump的备份原理及备份过程。

一、打开general_log

root@localhost [(none)]>set global general_log=1;
Query OK, 0 rows affected (0.00 sec)

root@localhost [(none)]>show global variables like '%general%';
+------------------+-----------------------------------+
| Variable_name    | Value                             |
+------------------+-----------------------------------+
| general_log      | ON                                |
| general_log_file | /storage/mysql/data/localhost.log |
+------------------+-----------------------------------+
2 rows in set (0.00 sec)

二、开始备份

/usr/local/mysql/bin/mysqldump -uroot -p -A --master-data=1 --single-transaction=1 >/tmp/dump.log

参数说明:

  1. -A备份全库

  2. master-data记录备份位置点

3.single-transaction避免锁表

三、查看general log

/usr/local/mysql/bin/mysqld, Version: 5.7.20-log (MySQL Community Server (GPL)). started with:
Tcp port: 3306  Unix socket: /tmp/mysql3306.sock
Time                 Id Command    Argument
2018-04-16T02:49:57.340776Z     5 Connect   root@localhost on  using Socket
2018-04-16T02:49:57.340818Z     5 Query /*!40100 SET @@SQL_MODE='' */
2018-04-16T02:49:57.340871Z     5 Query /*!40103 SET TIME_ZONE='+00:00' */
2018-04-16T02:49:57.340985Z     5 Query FLUSH /*!40101 LOCAL */ TABLES
2018-04-16T02:49:57.349781Z     5 Query FLUSH TABLES WITH READ LOCK
2018-04-16T02:49:57.349874Z     5 Query SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
2018-04-16T02:49:57.350204Z     5 Query START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
2018-04-16T02:49:57.350484Z     5 Query SHOW VARIABLES LIKE 'gtid\_mode'
2018-04-16T02:49:57.352560Z     5 Query SELECT @@GLOBAL.GTID_EXECUTED
2018-04-16T02:49:57.352665Z     5 Query SHOW MASTER STATUS
2018-04-16T02:49:57.352708Z     5 Query UNLOCK TABLES
2018-04-16T02:49:57.352781Z     5 Query SELECT LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'UNDO LOG' AND FILE_NAME IS NOT NULL AND LOGFILE_GROUP_NAME IS NOT NULL GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE ORDER BY LOGFILE_GROUP_NAME
2018-04-16T02:49:57.353360Z     5 Query SELECT DISTINCT TABLESPACE_NAME, FILE_NAME, LOGFILE_GROUP_NAME, EXTENT_SIZE, INITIAL_SIZE, ENGINE FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'DATAFILE' ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME
2018-04-16T02:49:57.354506Z     5 Query SHOW DATABASES
2018-04-16T02:49:57.364135Z     5 Query SHOW VARIABLES LIKE 'ndbinfo\_version'
2018-04-16T02:49:57.368598Z     5 Init DB   mysql
2018-04-16T02:49:57.368680Z     5 Query SHOW CREATE DATABASE IF NOT EXISTS `mysql`
2018-04-16T02:49:57.368728Z     5 Query SAVEPOINT sp
2018-04-16T02:49:57.368768Z     5 Query show tables
2018-04-16T02:49:57.368954Z     5 Query show table status like 'columns\_priv'
2018-04-16T02:49:57.369379Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.369422Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.369459Z     5 Query show create table `columns_priv`
2018-04-16T02:49:57.369519Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.369558Z     5 Query show fields from `columns_priv`
2018-04-16T02:49:57.369794Z     5 Query show fields from `columns_priv`
2018-04-16T02:49:57.370066Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `columns_priv`
2018-04-16T02:49:57.370157Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.370193Z     5 Query use `mysql`
2018-04-16T02:49:57.370230Z     5 Query select @@collation_database
2018-04-16T02:49:57.370275Z     5 Query SHOW TRIGGERS LIKE 'columns\_priv'
2018-04-16T02:49:57.370552Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.370599Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.370640Z     5 Query show table status like 'db'
2018-04-16T02:49:57.371756Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.371809Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.371844Z     5 Query show create table `db`
2018-04-16T02:49:57.371911Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.371954Z     5 Query show fields from `db`
2018-04-16T02:49:57.372316Z     5 Query show fields from `db`
2018-04-16T02:49:57.372598Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `db`
2018-04-16T02:49:57.372722Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.372727Z     5 Query use `mysql`
2018-04-16T02:49:57.372727Z     5 Query select @@collation_database
2018-04-16T02:49:57.372751Z     5 Query SHOW TRIGGERS LIKE 'db'
2018-04-16T02:49:57.373088Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.373127Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.373163Z     5 Query show table status like 'engine\_cost'
2018-04-16T02:49:57.373388Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.374807Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.375378Z     5 Query show create table `engine_cost`
2018-04-16T02:49:57.375591Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.375693Z     5 Query show fields from `engine_cost`
2018-04-16T02:49:57.376387Z     5 Query show fields from `engine_cost`
2018-04-16T02:49:57.376951Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `engine_cost`
2018-04-16T02:49:57.377090Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.377127Z     5 Query use `mysql`
2018-04-16T02:49:57.377195Z     5 Query select @@collation_database
2018-04-16T02:49:57.377240Z     5 Query SHOW TRIGGERS LIKE 'engine\_cost'
2018-04-16T02:49:57.377532Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.377567Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.377601Z     5 Query show table status like 'event'
2018-04-16T02:49:57.377841Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.377871Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.378429Z     5 Query show create table `event`
2018-04-16T02:49:57.378569Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.378611Z     5 Query show fields from `event`
2018-04-16T02:49:57.378923Z     5 Query show fields from `event`
2018-04-16T02:49:57.379190Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `event`
2018-04-16T02:49:57.379292Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.379324Z     5 Query use `mysql`
2018-04-16T02:49:57.379403Z     5 Query select @@collation_database
2018-04-16T02:49:57.379445Z     5 Query SHOW TRIGGERS LIKE 'event'
2018-04-16T02:49:57.379680Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.379713Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.379745Z     5 Query show table status like 'func'
2018-04-16T02:49:57.379848Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.379849Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.379849Z     5 Query show create table `func`
2018-04-16T02:49:57.379864Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.379901Z     5 Query show fields from `func`
2018-04-16T02:49:57.380135Z     5 Query show fields from `func`
2018-04-16T02:49:57.380326Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `func`
2018-04-16T02:49:57.380389Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.380418Z     5 Query use `mysql`
2018-04-16T02:49:57.380787Z     5 Query select @@collation_database
2018-04-16T02:49:57.380849Z     5 Query SHOW TRIGGERS LIKE 'func'
2018-04-16T02:49:57.381077Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.381110Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.381142Z     5 Query show table status like 'help\_category'
2018-04-16T02:49:57.384920Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.385031Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.385074Z     5 Query show create table `help_category`
2018-04-16T02:49:57.385153Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.385209Z     5 Query show fields from `help_category`
2018-04-16T02:49:57.385628Z     5 Query show fields from `help_category`
2018-04-16T02:49:57.385867Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `help_category`
2018-04-16T02:49:57.386083Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.386124Z     5 Query use `mysql`
2018-04-16T02:49:57.386164Z     5 Query select @@collation_database
2018-04-16T02:49:57.386209Z     5 Query SHOW TRIGGERS LIKE 'help\_category'
2018-04-16T02:49:57.386629Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.386675Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.386715Z     5 Query show table status like 'help\_keyword'
2018-04-16T02:49:57.388778Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.388845Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.389041Z     5 Query show create table `help_keyword`
2018-04-16T02:49:57.390043Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.390760Z     5 Query show fields from `help_keyword`
2018-04-16T02:49:57.391227Z     5 Query show fields from `help_keyword`
2018-04-16T02:49:57.391581Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `help_keyword`
2018-04-16T02:49:57.392486Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.392533Z     5 Query use `mysql`
2018-04-16T02:49:57.392605Z     5 Query select @@collation_database
2018-04-16T02:49:57.392656Z     5 Query SHOW TRIGGERS LIKE 'help\_keyword'
2018-04-16T02:49:57.393672Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.393727Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.393767Z     5 Query show table status like 'help\_relation'
2018-04-16T02:49:57.395610Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.395676Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.395720Z     5 Query show create table `help_relation`
2018-04-16T02:49:57.395786Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.395833Z     5 Query show fields from `help_relation`
2018-04-16T02:49:57.396137Z     5 Query show fields from `help_relation`
2018-04-16T02:49:57.396362Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `help_relation`
2018-04-16T02:49:57.397177Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.397222Z     5 Query use `mysql`
2018-04-16T02:49:57.397276Z     5 Query select @@collation_database
2018-04-16T02:49:57.397320Z     5 Query SHOW TRIGGERS LIKE 'help\_relation'
2018-04-16T02:49:57.397519Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.397554Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.397587Z     5 Query show table status like 'help\_topic'
2018-04-16T02:49:57.400086Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.400176Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.400221Z     5 Query show create table `help_topic`
2018-04-16T02:49:57.400291Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.400333Z     5 Query show fields from `help_topic`
2018-04-16T02:49:57.400763Z     5 Query show fields from `help_topic`
2018-04-16T02:49:57.400905Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `help_topic`
2018-04-16T02:49:57.412657Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.412714Z     5 Query use `mysql`
2018-04-16T02:49:57.412778Z     5 Query select @@collation_database
2018-04-16T02:49:57.412830Z     5 Query SHOW TRIGGERS LIKE 'help\_topic'
2018-04-16T02:49:57.413155Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.413190Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.413224Z     5 Query show table status like 'innodb\_index\_stats'
2018-04-16T02:49:57.414208Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.414256Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.414291Z     5 Query show create table `innodb_index_stats`
2018-04-16T02:49:57.414351Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.414391Z     5 Query show fields from `innodb_index_stats`
2018-04-16T02:49:57.414733Z     5 Query show fields from `innodb_index_stats`
2018-04-16T02:49:57.415177Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `innodb_index_stats`
2018-04-16T02:49:57.415349Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.415629Z     5 Query use `mysql`
2018-04-16T02:49:57.415718Z     5 Query select @@collation_database
2018-04-16T02:49:57.415785Z     5 Query SHOW TRIGGERS LIKE 'innodb\_index\_stats'
2018-04-16T02:49:57.416431Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.416495Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.416540Z     5 Query show table status like 'innodb\_table\_stats'
2018-04-16T02:49:57.418481Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.418611Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.418654Z     5 Query show create table `innodb_table_stats`
2018-04-16T02:49:57.418718Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.418759Z     5 Query show fields from `innodb_table_stats`
2018-04-16T02:49:57.419108Z     5 Query show fields from `innodb_table_stats`
2018-04-16T02:49:57.419338Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `innodb_table_stats`
2018-04-16T02:49:57.419560Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.419629Z     5 Query use `mysql`
2018-04-16T02:49:57.419695Z     5 Query select @@collation_database
2018-04-16T02:49:57.419745Z     5 Query SHOW TRIGGERS LIKE 'innodb\_table\_stats'
2018-04-16T02:49:57.420213Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.420256Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.420294Z     5 Query show table status like 'ndb\_binlog\_index'
2018-04-16T02:49:57.421195Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.421241Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.421276Z     5 Query show create table `ndb_binlog_index`
2018-04-16T02:49:57.421333Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.421375Z     5 Query show fields from `ndb_binlog_index`
2018-04-16T02:49:57.422813Z     5 Query show fields from `ndb_binlog_index`
2018-04-16T02:49:57.424468Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `ndb_binlog_index`
2018-04-16T02:49:57.424712Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.424773Z     5 Query use `mysql`
2018-04-16T02:49:57.424878Z     5 Query select @@collation_database
2018-04-16T02:49:57.424999Z     5 Query SHOW TRIGGERS LIKE 'ndb\_binlog\_index'
2018-04-16T02:49:57.425318Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.425356Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.425391Z     5 Query show table status like 'plugin'
2018-04-16T02:49:57.425760Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.425794Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.425825Z     5 Query show create table `plugin`
2018-04-16T02:49:57.426179Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.426265Z     5 Query show fields from `plugin`
2018-04-16T02:49:57.426597Z     5 Query show fields from `plugin`
2018-04-16T02:49:57.426793Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `plugin`
2018-04-16T02:49:57.426883Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.426884Z     5 Query use `mysql`
2018-04-16T02:49:57.426884Z     5 Query select @@collation_database
2018-04-16T02:49:57.426884Z     5 Query SHOW TRIGGERS LIKE 'plugin'
2018-04-16T02:49:57.427096Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.427134Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.427170Z     5 Query show table status like 'proc'
2018-04-16T02:49:57.428638Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.428694Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.428734Z     5 Query show create table `proc`
2018-04-16T02:49:57.428818Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.428866Z     5 Query show fields from `proc`
2018-04-16T02:49:57.429295Z     5 Query show fields from `proc`
2018-04-16T02:49:57.429672Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `proc` WHERE db != 'sys'
2018-04-16T02:49:57.429860Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.429897Z     5 Query use `mysql`
2018-04-16T02:49:57.429934Z     5 Query select @@collation_database
2018-04-16T02:49:57.429939Z     5 Query SHOW TRIGGERS LIKE 'proc'
2018-04-16T02:49:57.430000Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.430057Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.430095Z     5 Query show table status like 'procs\_priv'
2018-04-16T02:49:57.430342Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.430373Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.430403Z     5 Query show create table `procs_priv`
2018-04-16T02:49:57.431264Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.431416Z     5 Query show fields from `procs_priv`
2018-04-16T02:49:57.431870Z     5 Query show fields from `procs_priv`
2018-04-16T02:49:57.433097Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `procs_priv`
2018-04-16T02:49:57.433253Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.433300Z     5 Query use `mysql`
2018-04-16T02:49:57.433432Z     5 Query select @@collation_database
2018-04-16T02:49:57.433494Z     5 Query SHOW TRIGGERS LIKE 'procs\_priv'
2018-04-16T02:49:57.433814Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.433814Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.433815Z     5 Query show table status like 'proxies\_priv'
2018-04-16T02:49:57.435368Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.435477Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.435579Z     5 Query show create table `proxies_priv`
2018-04-16T02:49:57.435670Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.435717Z     5 Query show fields from `proxies_priv`
2018-04-16T02:49:57.436327Z     5 Query show fields from `proxies_priv`
2018-04-16T02:49:57.436630Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `proxies_priv`
2018-04-16T02:49:57.436729Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.436764Z     5 Query use `mysql`
2018-04-16T02:49:57.436835Z     5 Query select @@collation_database
2018-04-16T02:49:57.436882Z     5 Query SHOW TRIGGERS LIKE 'proxies\_priv'
2018-04-16T02:49:57.438374Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.438730Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.438807Z     5 Query show table status like 'server\_cost'
2018-04-16T02:49:57.440420Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.440483Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.440521Z     5 Query show create table `server_cost`
2018-04-16T02:49:57.440570Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.440598Z     5 Query show fields from `server_cost`
2018-04-16T02:49:57.440855Z     5 Query show fields from `server_cost`
2018-04-16T02:49:57.441196Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `server_cost`
2018-04-16T02:49:57.441313Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.441345Z     5 Query use `mysql`
2018-04-16T02:49:57.441402Z     5 Query select @@collation_database
2018-04-16T02:49:57.441445Z     5 Query SHOW TRIGGERS LIKE 'server\_cost'
2018-04-16T02:49:57.441618Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.441657Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.441691Z     5 Query show table status like 'servers'
2018-04-16T02:49:57.441957Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.441995Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.442026Z     5 Query show create table `servers`
2018-04-16T02:49:57.442081Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.442117Z     5 Query show fields from `servers`
2018-04-16T02:49:57.442334Z     5 Query show fields from `servers`
2018-04-16T02:49:57.442555Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `servers`
2018-04-16T02:49:57.442637Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.442668Z     5 Query use `mysql`
2018-04-16T02:49:57.442699Z     5 Query select @@collation_database
2018-04-16T02:49:57.442745Z     5 Query SHOW TRIGGERS LIKE 'servers'
2018-04-16T02:49:57.443624Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.443666Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.443701Z     5 Query show table status like 'slave\_master\_info'
2018-04-16T02:49:57.443942Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.443972Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.444000Z     5 Query show create table `slave_master_info`
2018-04-16T02:49:57.444069Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.444107Z     5 Query show fields from `slave_master_info`
2018-04-16T02:49:57.444471Z     5 Query show fields from `slave_master_info`
2018-04-16T02:49:57.444756Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.444801Z     5 Query use `mysql`
2018-04-16T02:49:57.444841Z     5 Query select @@collation_database
2018-04-16T02:49:57.444841Z     5 Query SHOW TRIGGERS LIKE 'slave\_master\_info'
2018-04-16T02:49:57.445007Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.445041Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.445076Z     5 Query show table status like 'slave\_relay\_log\_info'
2018-04-16T02:49:57.445295Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.445326Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.445355Z     5 Query show create table `slave_relay_log_info`
2018-04-16T02:49:57.445484Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.446157Z     5 Query show fields from `slave_relay_log_info`
2018-04-16T02:49:57.446517Z     5 Query show fields from `slave_relay_log_info`
2018-04-16T02:49:57.446748Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.446790Z     5 Query use `mysql`
2018-04-16T02:49:57.446847Z     5 Query select @@collation_database
2018-04-16T02:49:57.446891Z     5 Query SHOW TRIGGERS LIKE 'slave\_relay\_log\_info'
2018-04-16T02:49:57.447298Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.447340Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.447378Z     5 Query show table status like 'slave\_worker\_info'
2018-04-16T02:49:57.447675Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.447719Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.447752Z     5 Query show create table `slave_worker_info`
2018-04-16T02:49:57.447813Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.447852Z     5 Query show fields from `slave_worker_info`
2018-04-16T02:49:57.448127Z     5 Query show fields from `slave_worker_info`
2018-04-16T02:49:57.448359Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `slave_worker_info`
2018-04-16T02:49:57.448482Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.448517Z     5 Query use `mysql`
2018-04-16T02:49:57.448553Z     5 Query select @@collation_database
2018-04-16T02:49:57.448594Z     5 Query SHOW TRIGGERS LIKE 'slave\_worker\_info'
2018-04-16T02:49:57.448852Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.448888Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.449222Z     5 Query show table status like 'tables\_priv'
2018-04-16T02:49:57.449777Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.450515Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.450641Z     5 Query show create table `tables_priv`
2018-04-16T02:49:57.450713Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.450759Z     5 Query show fields from `tables_priv`
2018-04-16T02:49:57.451428Z     5 Query show fields from `tables_priv`
2018-04-16T02:49:57.451749Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `tables_priv`
2018-04-16T02:49:57.451883Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.451920Z     5 Query use `mysql`
2018-04-16T02:49:57.451989Z     5 Query select @@collation_database
2018-04-16T02:49:57.452034Z     5 Query SHOW TRIGGERS LIKE 'tables\_priv'
2018-04-16T02:49:57.452498Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.452541Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.452580Z     5 Query show table status like 'time\_zone'
2018-04-16T02:49:57.455651Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.455777Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.455825Z     5 Query show create table `time_zone`
2018-04-16T02:49:57.455956Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.456006Z     5 Query show fields from `time_zone`
2018-04-16T02:49:57.456323Z     5 Query show fields from `time_zone`
2018-04-16T02:49:57.456736Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `time_zone`
2018-04-16T02:49:57.456849Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.456855Z     5 Query use `mysql`
2018-04-16T02:49:57.456855Z     5 Query select @@collation_database
2018-04-16T02:49:57.456856Z     5 Query SHOW TRIGGERS LIKE 'time\_zone'
2018-04-16T02:49:57.457149Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.457187Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.457224Z     5 Query show table status like 'time\_zone\_leap\_second'
2018-04-16T02:49:57.458266Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.458307Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.458339Z     5 Query show create table `time_zone_leap_second`
2018-04-16T02:49:57.458390Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.458429Z     5 Query show fields from `time_zone_leap_second`
2018-04-16T02:49:57.458669Z     5 Query show fields from `time_zone_leap_second`
2018-04-16T02:49:57.458944Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `time_zone_leap_second`
2018-04-16T02:49:57.459037Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.459072Z     5 Query use `mysql`
2018-04-16T02:49:57.459131Z     5 Query select @@collation_database
2018-04-16T02:49:57.459176Z     5 Query SHOW TRIGGERS LIKE 'time\_zone\_leap\_second'
2018-04-16T02:49:57.459458Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.459495Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.459530Z     5 Query show table status like 'time\_zone\_name'
2018-04-16T02:49:57.459741Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.459772Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.459802Z     5 Query show create table `time_zone_name`
2018-04-16T02:49:57.459849Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.460361Z     5 Query show fields from `time_zone_name`
2018-04-16T02:49:57.460729Z     5 Query show fields from `time_zone_name`
2018-04-16T02:49:57.460977Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `time_zone_name`
2018-04-16T02:49:57.461111Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.461148Z     5 Query use `mysql`
2018-04-16T02:49:57.461213Z     5 Query select @@collation_database
2018-04-16T02:49:57.461257Z     5 Query SHOW TRIGGERS LIKE 'time\_zone\_name'
2018-04-16T02:49:57.461533Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.461569Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.461604Z     5 Query show table status like 'time\_zone\_transition'
2018-04-16T02:49:57.461810Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.461842Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.461871Z     5 Query show create table `time_zone_transition`
2018-04-16T02:49:57.461918Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.461918Z     5 Query show fields from `time_zone_transition`
2018-04-16T02:49:57.461921Z     5 Query show fields from `time_zone_transition`
2018-04-16T02:49:57.462092Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `time_zone_transition`
2018-04-16T02:49:57.462181Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.462212Z     5 Query use `mysql`
2018-04-16T02:49:57.462244Z     5 Query select @@collation_database
2018-04-16T02:49:57.462284Z     5 Query SHOW TRIGGERS LIKE 'time\_zone\_transition'
2018-04-16T02:49:57.463295Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.463396Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.463433Z     5 Query show table status like 'time\_zone\_transition\_type'
2018-04-16T02:49:57.463626Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.463666Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.463697Z     5 Query show create table `time_zone_transition_type`
2018-04-16T02:49:57.463752Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.463789Z     5 Query show fields from `time_zone_transition_type`
2018-04-16T02:49:57.464036Z     5 Query show fields from `time_zone_transition_type`
2018-04-16T02:49:57.464262Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `time_zone_transition_type`
2018-04-16T02:49:57.464358Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.464392Z     5 Query use `mysql`
2018-04-16T02:49:57.464427Z     5 Query select @@collation_database
2018-04-16T02:49:57.464468Z     5 Query SHOW TRIGGERS LIKE 'time\_zone\_transition\_type'
2018-04-16T02:49:57.464708Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.464749Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.464784Z     5 Query show table status like 'user'
2018-04-16T02:49:57.465133Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.465173Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.465208Z     5 Query show create table `user`
2018-04-16T02:49:57.465314Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.465363Z     5 Query show fields from `user`
2018-04-16T02:49:57.467603Z     5 Query show fields from `user`
2018-04-16T02:49:57.468580Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `user`
2018-04-16T02:49:57.469348Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.469395Z     5 Query use `mysql`
2018-04-16T02:49:57.469460Z     5 Query select @@collation_database
2018-04-16T02:49:57.469517Z     5 Query SHOW TRIGGERS LIKE 'user'
2018-04-16T02:49:57.472364Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.472569Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.472638Z     5 Query RELEASE SAVEPOINT sp
2018-04-16T02:49:57.472651Z     5 Query show table status like 'general\_log'
2018-04-16T02:49:57.473893Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.473946Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.473982Z     5 Query show create table `general_log`
2018-04-16T02:49:57.474126Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.474189Z     5 Query show fields from `general_log`
2018-04-16T02:49:57.474473Z     5 Query show fields from `general_log`
2018-04-16T02:49:57.474704Z     5 Query show table status like 'slow\_log'
2018-04-16T02:49:57.476210Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.476262Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.476301Z     5 Query show create table `slow_log`
2018-04-16T02:49:57.476366Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.476412Z     5 Query show fields from `slow_log`
2018-04-16T02:49:57.477747Z     5 Query show fields from `slow_log`
2018-04-16T02:49:57.478026Z     5 Init DB   xucl
2018-04-16T02:49:57.478063Z     5 Query SHOW CREATE DATABASE IF NOT EXISTS `xucl`
2018-04-16T02:49:57.478122Z     5 Query SAVEPOINT sp
2018-04-16T02:49:57.478156Z     5 Query show tables
2018-04-16T02:49:57.478277Z     5 Query show table status like 't'
2018-04-16T02:49:57.484854Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.484946Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.484994Z     5 Query show create table `t`
2018-04-16T02:49:57.485053Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.485177Z     5 Query show fields from `t`
2018-04-16T02:49:57.485452Z     5 Query show fields from `t`
2018-04-16T02:49:57.485643Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `t`
2018-04-16T02:49:57.485738Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.485745Z     5 Query use `xucl`
2018-04-16T02:49:57.485746Z     5 Query select @@collation_database
2018-04-16T02:49:57.485746Z     5 Query SHOW TRIGGERS LIKE 't'
2018-04-16T02:49:57.486028Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.486073Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.486116Z     5 Query show table status like 't1'
2018-04-16T02:49:57.487247Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.487404Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.487475Z     5 Query show create table `t1`
2018-04-16T02:49:57.487572Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.487674Z     5 Query show fields from `t1`
2018-04-16T02:49:57.487929Z     5 Query show fields from `t1`
2018-04-16T02:49:57.488236Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1`
2018-04-16T02:49:57.490837Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.491087Z     5 Query use `xucl`
2018-04-16T02:49:57.491188Z     5 Query select @@collation_database
2018-04-16T02:49:57.491258Z     5 Query SHOW TRIGGERS LIKE 't1'
2018-04-16T02:49:57.491863Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.491863Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.491864Z     5 Query show table status like 'user'
2018-04-16T02:49:57.493604Z     5 Query SET SQL_QUOTE_SHOW_CREATE=1
2018-04-16T02:49:57.493662Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.493702Z     5 Query show create table `user`
2018-04-16T02:49:57.493806Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.493854Z     5 Query show fields from `user`
2018-04-16T02:49:57.494333Z     5 Query show fields from `user`
2018-04-16T02:49:57.494698Z     5 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `user`
2018-04-16T02:49:57.495340Z     5 Query SET SESSION character_set_results = 'binary'
2018-04-16T02:49:57.495385Z     5 Query use `xucl`
2018-04-16T02:49:57.495499Z     5 Query select @@collation_database
2018-04-16T02:49:57.495581Z     5 Query SHOW TRIGGERS LIKE 'user'
2018-04-16T02:49:57.495871Z     5 Query SET SESSION character_set_results = 'utf8'
2018-04-16T02:49:57.495909Z     5 Query ROLLBACK TO SAVEPOINT sp
2018-04-16T02:49:57.495965Z     5 Query RELEASE SAVEPOINT sp
2018-04-16T02:49:57.506959Z     5 Quit  

4.解析备份过程

通过general log可以看到,首先进行的是FLUSH TABLES操作,即关闭所有打开的表,然后给所有表加上只读锁,接着开启更改会话级隔离等级为RR,开启一致性快照,获取复制信息,​释放全局读锁,然后就是结合save point一个表一个表导出数据,只到最后结束,断开连接,原事务中止。
结合下面的流程图看就比较清晰了:

mysqldump流程图

你可能感兴趣的:(【MySQL】深入理解mysqldump过程)