Single-transaction 与锁表时间有关
打开 show variable like '%gen%'
先建回滚点,然后打开,然后释放
$
>> mysqldump -uroot -p --protocol=TCP --port=$port --single-transaction --databases testdb > 1.sql
===========================================================================================================
180226 12:18:00 332732 Connect [email protected] on
332732 Connect Access denied for user 'root'@'127.0.0.1' (using password: YES)
180226 12:18:04 332733 Connect [email protected] on
332733 Query /*!40100 SET @@SQL_MODE='' */
332733 Query /*!40103 SET TIME_ZONE='+00:00' */
332733 Query SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ ///将事物隔离级别设置为可重复读
332733 Query START TRANSACTION /*!40100 WITH CONSISTENT SNAPSHOT */ ///开始事物,创建一致性快照
332733 Query SHOW VARIABLES LIKE 'gtid\_mode' ///查看GTID mode是否打开
332733 Query SELECT @@GLOBAL.GTID_EXECUTED ///查看当前执行的gtid
332733 Query UNLOCK TABLES ///解锁表
332733 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 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 ('testdb'))) GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE ORDER BY LOGFILE_GROUP_NAME
332733 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 ('testdb')) ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME
332733 Query SHOW VARIABLES LIKE 'ndbinfo\_version'
332733 Init DB testdb
332733 Query SHOW CREATE DATABASE IF NOT EXISTS `testdb`
332733 Query SAVEPOINT sp ///创建保存点
332733 Query show tables ///查看表
332733 Query show table status like 't\_account' ///查看表状态
332733 Query SET SQL_QUOTE_SHOW_CREATE=1 ///打开查看见表语句
332733 Query SET SESSION character_set_results = 'binary'
332733 Query show create table `t_account`
332733 Query SET SESSION character_set_results = 'utf8'
332733 Query show fields from `t_account`
332733 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `t_account`
332733 Query SET SESSION character_set_results = 'binary'
332733 Query use `testdb`
332733 Query select @@collation_database
332733 Query SHOW TRIGGERS LIKE 't\_account'
332733 Query SET SESSION character_set_results = 'utf8'
332733 Query ROLLBACK TO SAVEPOINT sp ///回滚到保存点
332733 Query RELEASE SAVEPOINT sp
332733 Quit
--Single-transaction对所有表全程加读锁
mysqldump -uroot -p --protocol=TCP --port=$port --databases testdb > 2.sql
====================================================================================================================
180226 15:33:26 332964 Connect [email protected] on
332964 Query /*!40100 SET @@SQL_MODE='' */
332964 Query /*!40103 SET TIME_ZONE='+00:00' */
332964 Query SHOW VARIABLES LIKE 'gtid\_mode'
332964 Query SELECT @@GLOBAL.GTID_EXECUTED
332964 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 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 ('testdb'))) GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE ORDER B
Y LOGFILE_GROUP_NAME
332964 Query SELECT DISTINCT TABLESPACE_NAME, FILE_NAME, LOGFILE_GROUP_NAME, EXTENT_SIZE, INITIAL_SIZE, ENGINE FROM INFORMATION_SCHEMA.FILES WHERE F
ILE_TYPE = 'DATAFILE' AND TABLESPACE_NAME IN (SELECT DISTINCT TABLESPACE_NAME FROM INFORMATION_SCHEMA.PARTITIONS WHERE TABLE_SCHEMA IN ('testdb')) ORDER BY TABLESPAC
E_NAME, LOGFILE_GROUP_NAME
332964 Query SHOW VARIABLES LIKE 'ndbinfo\_version'
332964 Init DB testdb
332964 Query SHOW CREATE DATABASE IF NOT EXISTS `testdb`
332964 Query show tables
332964 Query LOCK TABLES `t_account` READ /*!32311 LOCAL */,`t_user` READ /*!32311 LOCAL */
332964 Query show table status like 't\_account'
332964 Query SET SQL_QUOTE_SHOW_CREATE=1
332964 Query SET SESSION character_set_results = 'binary'
332964 Query show create table `t_account`
332964 Query SET SESSION character_set_results = 'utf8'
332964 Query show fields from `t_account`
332964 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `t_account`
332964 Query SET SESSION character_set_results = 'binary'
332964 Query use `testdb`
332964 Query select @@collation_database
332964 Query SHOW TRIGGERS LIKE 't\_account'
332964 Query SET SESSION character_set_results = 'utf8'
332964 Query SET SESSION character_set_results = 'binary'
332964 Query use `testdb`
332964 Query select @@collation_database
332964 Query SHOW TRIGGERS LIKE 't\_user'
332964 Query SET SESSION character_set_results = 'utf8'
332964 Query show table status like 't\_user'
332964 Query SET SQL_QUOTE_SHOW_CREATE=1
332964 Query SET SESSION character_set_results = 'binary'
332964 Query show create table `t_user`
332964 Query SET SESSION character_set_results = 'utf8'
332964 Query show fields from `t_user`
332964 Query SELECT /*!40001 SQL_NO_CACHE */ * FROM `t_user`
332964 Query SET SESSION character_set_results = 'binary'
332964 Query UNLOCK TABLES
332964 Quit