温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

mysqldump内部实现原理的示例分析

发布时间:2021-11-02 17:20:24 来源:亿速云 阅读:308 作者:小新 栏目:MySQL数据库

小编给大家分享一下mysqldump内部实现原理的示例分析,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!

我们可以通过打开general log,查看mysqldump全库备份时执行的命令来了解mysqldump背后的原理。

打开general log
mysql> set global general_log=on;
其中,general log的存放路径可通过以下命令查看
mysql> show variables like '%general_log_file%';

总结
1、--master-data产生如下,会导致mysqldump期间无法执行DDL和DML,而且执行mysqldump之前表有锁,则mysqldump会等待,导出结果是发生mysqldump这一刻的数据
FLUSH /*!40101 LOCAL */ TABLES和FLUSH TABLES WITH READ LOCK和SHOW MASTER STATUS

2、--lock-all-tables产生如下,会导致mysqldump期间无法执行DDL和DML,而且执行mysqldump之前表有锁,则mysqldump会等待,导出结果是发生mysqldump这一刻的数据
FLUSH TABLES和FLUSH TABLES WITH READ LOCK

3、--master-data和--lock-all-tables同时使用时,效果和--master-data一致

4、--single-transaction产生如下,mysqldump期间不影响DML和DDL,但是mysqldump本身可能受DDL影响而报错退出,mysqldump之前表有锁,mysqldump也不会等待,导出结果是发生mysqldump这一刻的数据
UNLOCK TABLES,SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ,SAVEPOINT,ROLLBACK TO SAVEPOINT,RELEASE SAVEPOINT

5、--skip-lock-tables不产生任何LOCK,mysqldump期间不影响DML和DDL,但是mysqldump本身可能受DDL影响而报错退出,mysqldump之前表有锁,mysqldump也不会等待,导出结果不是mysqldump这一刻的数据,而是导那张表的开始时刻就是该表的数据(比如导A表是8:00,则导出过程要一个小时,导出结果也是8:00的数据,导B表是9:00,则导出过程要一个小时,B的导出结果也是9:00的数据),和oracle 的expdp相似。

6、默认导出产生如下,会导致mysqldump期间,正在执行导出的库无法执行DDL和DML,没有在执行导出的库可以执行DDL和DML,mysqldump之前表有锁,mysqldump也不会等待,导出结果不是发生mysqldump这一刻的数据,而是导那个库的开始时刻就是那个库的数据(比如导A库是8:00,则导出过程要一个小时,A的导出结果也是8:00的数据,导B库是9:00,则导出过程要一个小时,B的导出结果也是9:00的数据)。
LOCK TABLES `table1` READ /*!32311 LOCAL */,`table2` READ /*!32311 LOCAL */
UNLOCK TABLES

7、生成建库语句,生成建表语句,备份的核心语句(该语句查询到表table1的所有数据,在备份文件中会生成相应的insert语句。其中SQL_NO_CACHE的作用是查询的结果并不会缓存到查询缓存中),分别如下
SHOW CREATE DATABASE IF NOT EXISTS `test1`
show create table `table1`
SELECT /*!40001 SQL_NO_CACHE */ * FROM `table1`

--master-data日志如下
有FLUSH /*!40101 LOCAL */ TABLES和FLUSH TABLES WITH READ LOCK和SHOW MASTER STATUS
没有任何UNLOCK
mysqldump  --master-data=2  --databases test1 > /home/test1_2.sql

2019-01-06T06:29:59.361208Z    4 Connect        root@localhost on  using Socket
2019-01-06T06:29:59.361337Z    4 Query  /*!40100 SET @@SQL_MODE='' */
2019-01-06T06:29:59.361434Z    4 Query  /*!40103 SET TIME_ZONE='+00:00' */
2019-01-06T06:29:59.361558Z    4 Query  FLUSH /*!40101 LOCAL */ TABLES
2019-01-06T06:29:59.369450Z    4 Query  FLUSH TABLES WITH READ LOCK
2019-01-06T06:29:59.369580Z    4 Query  SHOW VARIABLES LIKE 'gtid\_mode'
2019-01-06T06:29:59.372284Z    4 Query  SHOW MASTER STATUS
2019-01-06T06:29:59.372533Z    4 Query  SELECT ...
...
2019-01-06T06:29:59.375795Z    4 Query  SHOW VARIABLES LIKE 'ndbinfo\_version'
2019-01-06T06:29:59.378605Z    4 Init DB        test1
2019-01-06T06:29:59.378670Z    4 Query  SHOW CREATE DATABASE IF NOT EXISTS `test1`
2019-01-06T06:29:59.378767Z    4 Query  show tables
2019-01-06T06:29:59.379070Z    4 Query  show table status like 'table1'
2019-01-06T06:29:59.379457Z    4 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T06:29:59.379555Z    4 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:29:59.379649Z    4 Query  show create table `table1`
2019-01-06T06:29:59.379778Z    4 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:29:59.379940Z    4 Query  show fields from `table1`
2019-01-06T06:29:59.380463Z    4 Query  show fields from `table1`
2019-01-06T06:29:59.380933Z    4 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table1`
2019-01-06T06:29:59.381225Z    4 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:29:59.381323Z    4 Query  use `test1`
2019-01-06T06:29:59.381416Z    4 Query  select @@collation_database
2019-01-06T06:29:59.381546Z    4 Query  SHOW TRIGGERS LIKE 'table1'
2019-01-06T06:29:59.382209Z    4 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:29:59.382309Z    4 Query  show table status like 'table2'
2019-01-06T06:29:59.382597Z    4 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T06:29:59.382670Z    4 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:29:59.382746Z    4 Query  show create table `table2`
2019-01-06T06:29:59.382848Z    4 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:29:59.382983Z    4 Query  show fields from `table2`
2019-01-06T06:29:59.383385Z    4 Query  show fields from `table2`
2019-01-06T06:29:59.383782Z    4 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table2`
2019-01-06T06:29:59.384125Z    4 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:29:59.384223Z    4 Query  use `test1`
2019-01-06T06:29:59.384312Z    4 Query  select @@collation_database
2019-01-06T06:29:59.384430Z    4 Query  SHOW TRIGGERS LIKE 'table2'
2019-01-06T06:29:59.385032Z    4 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:29:59.420821Z    4 Quit


--single-transaction日志如下
没有FLUSH /*!40101 LOCAL */ TABLES和FLUSH TABLES WITH READ LOCK
只有UNLOCK TABLES,SAVEPOINT,ROLLBACK TO SAVEPOINT,RELEASE SAVEPOINT
mysqldump  --single-transaction  --databases test1 > /home/test1_2.sql

2019-01-06T06:16:52.542170Z    8 Connect        root@localhost on  using Socket
2019-01-06T06:16:52.542314Z    8 Query  /*!40100 SET @@SQL_MODE='' */
2019-01-06T06:16:52.542433Z    8 Query  /*!40103 SET TIME_ZONE='+00:00' */
2019-01-06T06:16:52.542593Z    8 Query  SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ
2019-01-06T06:16:52.542674Z    8 Query  START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */
2019-01-06T06:16:52.542794Z    8 Query  SHOW VARIABLES LIKE 'gtid\_mode'
2019-01-06T06:16:52.545877Z    8 Query  UNLOCK TABLES
2019-01-06T06:16:52.546158Z    8 Query  SELECT...
...
2019-01-06T06:16:52.550745Z    8 Query  SHOW VARIABLES LIKE 'ndbinfo\_version'
2019-01-06T06:16:52.553711Z    8 Init DB        test1
2019-01-06T06:16:52.553793Z    8 Query  SHOW CREATE DATABASE IF NOT EXISTS `test1`
2019-01-06T06:16:52.553896Z    8 Query  SAVEPOINT sp
2019-01-06T06:16:52.554040Z    8 Query  show tables
2019-01-06T06:16:52.554281Z    8 Query  show table status like 'table1'
2019-01-06T06:16:52.554665Z    8 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T06:16:52.554766Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:16:52.554862Z    8 Query  show create table `table1`
2019-01-06T06:16:52.555144Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:16:52.555263Z    8 Query  show fields from `table1`
2019-01-06T06:16:52.555766Z    8 Query  show fields from `table1`
2019-01-06T06:16:52.556323Z    8 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table1`
2019-01-06T06:16:52.556585Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:16:52.556682Z    8 Query  use `test1`
2019-01-06T06:16:52.556776Z    8 Query  select @@collation_database
2019-01-06T06:16:52.556908Z    8 Query  SHOW TRIGGERS LIKE 'table1'
2019-01-06T06:16:52.557623Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:16:52.557709Z    8 Query  ROLLBACK TO SAVEPOINT sp
2019-01-06T06:16:52.557793Z    8 Query  show table status like 'table2'
2019-01-06T06:16:52.558118Z    8 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T06:16:52.558191Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:16:52.558264Z    8 Query  show create table `table2`
2019-01-06T06:16:52.558391Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:16:52.558481Z    8 Query  show fields from `table2`
2019-01-06T06:16:52.558904Z    8 Query  show fields from `table2`
2019-01-06T06:16:52.559413Z    8 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table2`
2019-01-06T06:16:52.559580Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:16:52.559653Z    8 Query  use `test1`
2019-01-06T06:16:52.559726Z    8 Query  select @@collation_database
2019-01-06T06:16:52.559858Z    8 Query  SHOW TRIGGERS LIKE 'table2'
2019-01-06T06:16:52.560307Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:16:52.560378Z    8 Query  ROLLBACK TO SAVEPOINT sp
2019-01-06T06:16:52.560465Z    8 Query  RELEASE SAVEPOINT sp
2019-01-06T06:16:52.658772Z    8 Quit


--skip-lock-tables日志如下
没有FLUSH /*!40101 LOCAL */ TABLES和FLUSH TABLES WITH READ LOCK
也没有任何UNLOCK
mysqldump --skip-lock-tables --databases test2 > /home/test1_2.sql

2019-01-03T14:35:41.956739Z    7 Connect        root@localhost on  using Socket
2019-01-03T14:35:41.956875Z    7 Query  /*!40100 SET @@SQL_MODE='' */
2019-01-03T14:35:41.956976Z    7 Query  /*!40103 SET TIME_ZONE='+00:00' */
2019-01-03T14:35:41.957122Z    7 Query  SHOW VARIABLES LIKE 'gtid\_mode'
2019-01-03T14:35:41.959794Z    7 Query  SELECT ...
...
2019-01-03T14:35:41.965124Z    7 Query  SHOW VARIABLES LIKE 'ndbinfo\_version'
2019-01-03T14:35:41.967453Z    7 Init DB        test2
2019-01-03T14:35:41.967557Z    7 Query  SHOW CREATE DATABASE IF NOT EXISTS `test2`
2019-01-03T14:35:41.967659Z    7 Query  show tables
2019-01-03T14:35:41.967871Z    7 Query  show table status like 't1'
2019-01-03T14:35:41.968196Z    7 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-03T14:35:41.968279Z    7 Query  SET SESSION character_set_results = 'binary'
2019-01-03T14:35:41.968359Z    7 Query  show create table `t1`
2019-01-03T14:35:41.968468Z    7 Query  SET SESSION character_set_results = 'utf8'
2019-01-03T14:35:41.968690Z    7 Query  show fields from `t1`
2019-01-03T14:35:41.969127Z    7 Query  show fields from `t1`
2019-01-03T14:35:41.969589Z    7 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1`
2019-01-03T14:35:41.969824Z    7 Query  SET SESSION character_set_results = 'binary'
2019-01-03T14:35:41.969906Z    7 Query  use `test2`
2019-01-03T14:35:41.969986Z    7 Query  select @@collation_database
2019-01-03T14:35:41.970098Z    7 Query  SHOW TRIGGERS LIKE 't1'
2019-01-03T14:35:41.970753Z    7 Query  SET SESSION character_set_results = 'utf8'
2019-01-03T14:35:41.970855Z    7 Query  show table status like 't2'
2019-01-03T14:35:41.971246Z    7 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-03T14:35:41.971325Z    7 Query  SET SESSION character_set_results = 'binary'
2019-01-03T14:35:41.971404Z    7 Query  show create table `t2`
2019-01-03T14:35:41.971671Z    7 Query  SET SESSION character_set_results = 'utf8'
2019-01-03T14:35:41.971807Z    7 Query  show fields from `t2`
2019-01-03T14:35:41.972269Z    7 Query  show fields from `t2`
2019-01-03T14:35:41.972777Z    7 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `t2`


默认备份日志如下
没有FLUSH /*!40101 LOCAL */ TABLES和FLUSH TABLES WITH READ LOCK
但是有LOCK TABLES,结尾有UNLOCK TABLES
mysqldump --databases test2 > /home/test1_2.sql

2019-01-03T14:38:19.276575Z    8 Connect        root@localhost on  using Socket
2019-01-03T14:38:19.276814Z    8 Query  /*!40100 SET @@SQL_MODE='' */
2019-01-03T14:38:19.276918Z    8 Query  /*!40103 SET TIME_ZONE='+00:00' */
2019-01-03T14:38:19.277065Z    8 Query  SHOW VARIABLES LIKE 'gtid\_mode'
2019-01-03T14:38:19.279690Z    8 Query  SELECT ...
...
2019-01-03T14:38:19.285033Z    8 Query  SHOW VARIABLES LIKE 'ndbinfo\_version'
2019-01-03T14:38:19.287392Z    8 Init DB        test2
2019-01-03T14:38:19.287461Z    8 Query  SHOW CREATE DATABASE IF NOT EXISTS `test2`
2019-01-03T14:38:19.287559Z    8 Query  show tables
2019-01-03T14:38:19.287886Z    8 Query  LOCK TABLES `t1` READ /*!32311 LOCAL */,`t2` READ /*!32311 LOCAL */,`t3` READ /*!32311 LOCAL */,`t4` READ /*!32311 LOCAL */,`t7` READ /*!32311 LOCAL */
2019-01-03T14:38:19.288043Z    8 Query  show table status like 't1'
2019-01-03T14:38:19.288403Z    8 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-03T14:38:19.288488Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-03T14:38:19.288569Z    8 Query  show create table `t1`
2019-01-03T14:38:19.288714Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-03T14:38:19.288808Z    8 Query  show fields from `t1`
2019-01-03T14:38:19.289236Z    8 Query  show fields from `t1`
2019-01-03T14:38:19.289789Z    8 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `t1`
2019-01-03T14:38:19.290008Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-03T14:38:19.290090Z    8 Query  use `test2`
2019-01-03T14:38:19.290171Z    8 Query  select @@collation_database
2019-01-03T14:38:19.290281Z    8 Query  SHOW TRIGGERS LIKE 't1'
2019-01-03T14:38:19.290768Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-03T14:38:19.290869Z    8 Query  show table status like 't2'
2019-01-03T14:38:19.291184Z    8 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-03T14:38:19.291260Z    8 Query  SET SESSION character_set_results = 'binary'
2019-01-03T14:38:19.291338Z    8 Query  show create table `t2`
2019-01-03T14:38:19.291437Z    8 Query  SET SESSION character_set_results = 'utf8'
2019-01-03T14:38:19.291528Z    8 Query  show fields from `t2`
2019-01-03T14:38:19.292061Z    8 Query  show fields from `t2`
2019-01-03T14:38:19.292454Z    8 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `t2`
2019-01-03T14:38:19.292612Z    8 Query  SET SESSION character_set_results = 'binary'
...
2019-01-03T14:38:19.302719Z    8 Query  UNLOCK TABLES
2019-01-03T14:38:19.306712Z    8 Quit


--lock-all-tables
产生FLUSH TABLES和FLUSH TABLES WITH READ LOCK
没有任何UNLOCK
mysqldump  --lock-all-tables  --databases test1 > /home/test1_2.sql

2019-01-06T06:47:17.614479Z    5 Connect        root@localhost on  using Socket
2019-01-06T06:47:17.614801Z    5 Query  /*!40100 SET @@SQL_MODE='' */
2019-01-06T06:47:17.614922Z    5 Query  /*!40103 SET TIME_ZONE='+00:00' */
2019-01-06T06:47:17.615074Z    5 Query  FLUSH TABLES
2019-01-06T06:47:17.620471Z    5 Query  FLUSH TABLES WITH READ LOCK
2019-01-06T06:47:17.620629Z    5 Query  SHOW VARIABLES LIKE 'gtid\_mode'
2019-01-06T06:47:17.623672Z    5 Query  SELECT ...
...
2019-01-06T06:47:17.626996Z    5 Query  SHOW VARIABLES LIKE 'ndbinfo\_version'
2019-01-06T06:47:17.629714Z    5 Init DB        test1
2019-01-06T06:47:17.629798Z    5 Query  SHOW CREATE DATABASE IF NOT EXISTS `test1`
2019-01-06T06:47:17.629916Z    5 Query  show tables
2019-01-06T06:47:17.630154Z    5 Query  show table status like 'table1'
2019-01-06T06:47:17.630615Z    5 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T06:47:17.630702Z    5 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:47:17.630780Z    5 Query  show create table `table1`
2019-01-06T06:47:17.630889Z    5 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:47:17.630979Z    5 Query  show fields from `table1`
2019-01-06T06:47:17.631397Z    5 Query  show fields from `table1`
2019-01-06T06:47:17.632023Z    5 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table1`
2019-01-06T06:47:17.632286Z    5 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:47:17.632384Z    5 Query  use `test1`
2019-01-06T06:47:17.632479Z    5 Query  select @@collation_database
2019-01-06T06:47:17.632668Z    5 Query  SHOW TRIGGERS LIKE 'table1'
2019-01-06T06:47:17.633103Z    5 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:47:17.633202Z    5 Query  show table status like 'table2'
2019-01-06T06:47:17.633489Z    5 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T06:47:17.633713Z    5 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:47:17.633811Z    5 Query  show create table `table2`
2019-01-06T06:47:17.633937Z    5 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:47:17.634045Z    5 Query  show fields from `table2`
2019-01-06T06:47:17.634532Z    5 Query  show fields from `table2`
2019-01-06T06:47:17.635011Z    5 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table2`
2019-01-06T06:47:17.635177Z    5 Query  SET SESSION character_set_results = 'binary'
2019-01-06T06:47:17.635250Z    5 Query  use `test1`
2019-01-06T06:47:17.635317Z    5 Query  select @@collation_database
2019-01-06T06:47:17.635400Z    5 Query  SHOW TRIGGERS LIKE 'table2'
2019-01-06T06:47:17.635962Z    5 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T06:47:17.639473Z    5 Quit


--lock-all-tables  --master-data同时使用
mysqldump  --lock-all-tables  --master-data=2 --databases test1 > /home/test1_2.sql
2019-01-06T07:11:08.806918Z   10 Connect        root@localhost on  using Socket
2019-01-06T07:11:08.807047Z   10 Query  /*!40100 SET @@SQL_MODE='' */
2019-01-06T07:11:08.807174Z   10 Query  /*!40103 SET TIME_ZONE='+00:00' */
2019-01-06T07:11:08.807392Z   10 Query  FLUSH /*!40101 LOCAL */ TABLES
2019-01-06T07:11:08.807499Z   10 Query  FLUSH TABLES WITH READ LOCK
2019-01-06T07:11:08.807598Z   10 Query  SHOW VARIABLES LIKE 'gtid\_mode'
2019-01-06T07:11:08.810307Z   10 Query  SHOW MASTER STATUS
2019-01-06T07:11:08.810538Z   10 Query  SELECT ...
...
2019-01-06T07:11:08.813490Z   10 Query  SHOW VARIABLES LIKE 'ndbinfo\_version'
2019-01-06T07:11:08.815880Z   10 Init DB        test1
2019-01-06T07:11:08.815948Z   10 Query  SHOW CREATE DATABASE IF NOT EXISTS `test1`
2019-01-06T07:11:08.816048Z   10 Query  show tables
2019-01-06T07:11:08.816379Z   10 Query  show table status like 'table1'
2019-01-06T07:11:08.816703Z   10 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T07:11:08.816787Z   10 Query  SET SESSION character_set_results = 'binary'
2019-01-06T07:11:08.816868Z   10 Query  show create table `table1`
2019-01-06T07:11:08.816977Z   10 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T07:11:08.817070Z   10 Query  show fields from `table1`
2019-01-06T07:11:08.817533Z   10 Query  show fields from `table1`
2019-01-06T07:11:08.817952Z   10 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table1`
2019-01-06T07:11:08.818288Z   10 Query  SET SESSION character_set_results = 'binary'
2019-01-06T07:11:08.818376Z   10 Query  use `test1`
2019-01-06T07:11:08.818455Z   10 Query  select @@collation_database
2019-01-06T07:11:08.818567Z   10 Query  SHOW TRIGGERS LIKE 'table1'
2019-01-06T07:11:08.818996Z   10 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T07:11:08.819080Z   10 Query  show table status like 'table2'
2019-01-06T07:11:08.819376Z   10 Query  SET SQL_QUOTE_SHOW_CREATE=1
2019-01-06T07:11:08.819439Z   10 Query  SET SESSION character_set_results = 'binary'
2019-01-06T07:11:08.819503Z   10 Query  show create table `table2`
2019-01-06T07:11:08.819589Z   10 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T07:11:08.819664Z   10 Query  show fields from `table2`
2019-01-06T07:11:08.819993Z   10 Query  show fields from `table2`
2019-01-06T07:11:08.820434Z   10 Query  SELECT /*!40001 SQL_NO_CACHE */ * FROM `table2`
2019-01-06T07:11:08.820578Z   10 Query  SET SESSION character_set_results = 'binary'
2019-01-06T07:11:08.820644Z   10 Query  use `test1`
2019-01-06T07:11:08.820707Z   10 Query  select @@collation_database
2019-01-06T07:11:08.820789Z   10 Query  SHOW TRIGGERS LIKE 'table2'
2019-01-06T07:11:08.821171Z   10 Query  SET SESSION character_set_results = 'utf8'
2019-01-06T07:11:08.846442Z   10 Quit


SELECT ...
...
内如为
2019-01-01T06:16:52.546158Z    8 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 AND LOGFILE_GROUP_NAME IN (SELECT DISTINCT LOGFILE_GROUP_NAME FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('test1'))) GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE ORDER BY LOGFILE_GROUP_NAME
2019-01-01T06:16:52.549144Z    8 Query  SELECT DISTINCT TABLESPACE_NAME, FILE_NAME, LOGFILE_GROUP_NAME, EXTENT_SIZE, INITIAL_SIZE, ENGINE FROM INFORMATION_SCHEMA.FILES WHERE FILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('test1')) ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME

以上是“mysqldump内部实现原理的示例分析”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI