您好,登錄后才能下訂單哦!
小編給大家分享一下mysqldump內(nèi)部實現(xiàn)原理的示例分析,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
我們可以通過打開general log,查看mysqldump全庫備份時執(zhí)行的命令來了解mysqldump背后的原理。
打開general log
mysql> set global general_log=on;
其中,general log的存放路徑可通過以下命令查看
mysql> show variables like '%general_log_file%';
總結(jié)
1、--master-data產(chǎn)生如下,會導致mysqldump期間無法執(zhí)行DDL和DML,而且執(zhí)行mysqldump之前表有鎖,則mysqldump會等待,導出結(jié)果是發(fā)生mysqldump這一刻的數(shù)據(jù)
FLUSH /*!40101 LOCAL */ TABLES和FLUSH TABLES WITH READ LOCK和SHOW MASTER STATUS
2、--lock-all-tables產(chǎn)生如下,會導致mysqldump期間無法執(zhí)行DDL和DML,而且執(zhí)行mysqldump之前表有鎖,則mysqldump會等待,導出結(jié)果是發(fā)生mysqldump這一刻的數(shù)據(jù)
FLUSH TABLES和FLUSH TABLES WITH READ LOCK
3、--master-data和--lock-all-tables同時使用時,效果和--master-data一致
4、--single-transaction產(chǎn)生如下,mysqldump期間不影響DML和DDL,但是mysqldump本身可能受DDL影響而報錯退出,mysqldump之前表有鎖,mysqldump也不會等待,導出結(jié)果是發(fā)生mysqldump這一刻的數(shù)據(jù)
UNLOCK TABLES,SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ,SAVEPOINT,ROLLBACK TO SAVEPOINT,RELEASE SAVEPOINT
5、--skip-lock-tables不產(chǎn)生任何LOCK,mysqldump期間不影響DML和DDL,但是mysqldump本身可能受DDL影響而報錯退出,mysqldump之前表有鎖,mysqldump也不會等待,導出結(jié)果不是mysqldump這一刻的數(shù)據(jù),而是導那張表的開始時刻就是該表的數(shù)據(jù)(比如導A表是8:00,則導出過程要一個小時,導出結(jié)果也是8:00的數(shù)據(jù),導B表是9:00,則導出過程要一個小時,B的導出結(jié)果也是9:00的數(shù)據(jù)),和oracle 的expdp相似。
6、默認導出產(chǎn)生如下,會導致mysqldump期間,正在執(zhí)行導出的庫無法執(zhí)行DDL和DML,沒有在執(zhí)行導出的庫可以執(zhí)行DDL和DML,mysqldump之前表有鎖,mysqldump也不會等待,導出結(jié)果不是發(fā)生mysqldump這一刻的數(shù)據(jù),而是導那個庫的開始時刻就是那個庫的數(shù)據(jù)(比如導A庫是8:00,則導出過程要一個小時,A的導出結(jié)果也是8:00的數(shù)據(jù),導B庫是9:00,則導出過程要一個小時,B的導出結(jié)果也是9:00的數(shù)據(jù))。
LOCK TABLES `table1` READ /*!32311 LOCAL */,`table2` READ /*!32311 LOCAL */
UNLOCK TABLES
7、生成建庫語句,生成建表語句,備份的核心語句(該語句查詢到表table1的所有數(shù)據(jù),在備份文件中會生成相應的insert語句。其中SQL_NO_CACHE的作用是查詢的結(jié)果并不會緩存到查詢緩存中),分別如下
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,結(jié)尾有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
產(chǎn)生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 ...
...
內(nèi)如為
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內(nèi)部實現(xiàn)原理的示例分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業(yè)資訊頻道!
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。