mysqldump 参数--single-transaction
其实很简单,single-transaction可以让mysqldump 的时候不锁表。但是他有3个前提
- innodb的引擎
- 不能在执行的同时,有其他alter table ,drop table,rename table,truncate table的操作。
- 隔离级别 必须是REPEATABLE READ ,很多公司都会修改这个隔离级别的,比如阿里云的rds ,默认隔离级别是READ-COMMITTED
下面附上 mysqldump --help的 内容,和mysql 官网上的内容:
--single-transaction
Creates a consistent snapshot by dumping all tables in a
single transaction. Works ONLY for tables stored in
storage engines which support multiversioning (currently
only InnoDB does); the dump is NOT guaranteed to be
consistent for other storage engines. While a
--single-transaction dump is in process, to ensure a
valid dump file (correct table contents and binary log
position), no other connection should use the following
statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
TRUNCATE TABLE, as consistent snapshot is not isolated
from them. Option automatically turns off --lock-tables.
-
This option sets the transaction isolation mode to
REPEATABLE READ
and sends aSTART TRANSACTION
SQL statement to the server before dumping data. It is useful only with transactional tables such asInnoDB
, because then it dumps the consistent state of the database at the time whenSTART TRANSACTION
was issued without blocking any applications.When using this option, you should keep in mind that only
InnoDB
tables are dumped in a consistent state. For example, anyMyISAM
orMEMORY
tables dumped while using this option may still change state.While a
--single-transaction
dump is in process, to ensure a valid dump file (correct table contents and binary log coordinates), no other connection should use the following statements:ALTER TABLE
,CREATE TABLE
,DROP TABLE
,RENAME TABLE
,TRUNCATE TABLE
. A consistent read is not isolated from those statements, so use of them on a table to be dumped can cause theSELECT
that is performed by mysqldump to retrieve the table contents to obtain incorrect contents or fail.The
--single-transaction
option and the--lock-tables
option are mutually exclusive becauseLOCK TABLES
causes any pending transactions to be committed implicitly.This option is not supported for MySQL Cluster tables; the results cannot be guaranteed to be consistent due to the fact that the
NDBCLUSTER
storage engine supports only theREAD_COMMITTED
transaction isolation level. You should always useNDB
backup and restore instead.To dump large tables, combine the
--single-transaction
option with the--quick
option.
mysqldump 参数--single-transaction的更多相关文章
- Mysqldump 参数详解(全)
Mysqldump 参数详解(全) http://www.open-open.com/lib/view/open1358172843762.html mysqldump -S /tmp/mysql33 ...
- Mysqldump参数大全
Mysqldump参数大全(参数来源于mysql5.5.19源码) 参数 参数说明 --all-databases , -A 导出全部数据库. mysqldump -uroot -p --al ...
- mysqldump参数详细说明
Mysqldump参数大全(参数来源于mysql5.5.19源码) 参数 参数说明 --all-databases , -A 导出全部数据库. mysqldump -uroot -p --al ...
- mysqldump参数详细说明(转)
Mysqldump参数大全(参数来源于mysql5.5.19源码) 参数 参数说明 --all-databases , -A 导出全部数据库. mysqldump -uroot -p --al ...
- Mysqldump参数大全 这 些参数 不同于 mysql 的那些参数(下边文章开头有链接) :2 种类型的参数含义是不一样的
Mysqldump参数大全 这 些参数 不同于 mysql 的那些参数 :2 种类型的参数含义是不一样的 Mysqldump参数大全(参数来源于mysql5.5.19源码) 参数 参数说明 --a ...
- Mysqldump参数大全(转)
参数 参数说明 --all-databases , -A 导出全部数据库. mysqldump -uroot -p --all-databases --all-tablespaces , -Y ...
- MySQL命令mysqldump参数大全
参数参数说明--all-databases , -A导出全部数据库.mysqldump -uroot -p --all-databases--all-tablespaces , -Y导出全部表空 ...
- mysqldump 参数--lock-tables浅析
mysqldump有一个参数--lock-tables,以前对这个参数也没有详细了解过,直到上次有个网友问"参数lock-tables 是一次性锁定当前库的所有表,还是锁定当前导出表?&qu ...
- Mysqldump 参数大全
参数 参数说明 --all-databases , -A 导出全部数据库. mysqldump -uroot -p --all-databases --all-tablespaces , -Y ...
随机推荐
- 编程语言千千万,为什么学习Python的占一半?
如果让你从数百种的编程语言中选择一个入门语言?你会选择哪一个? 是应用率最高.长期霸占排行榜的常青藤 Java?是易于上手,难以精通的 C?还是在游戏和工具领域仍占主流地位的 C++?亦或是占据 Wi ...
- Nmap详细用法
探测主机存活 (1)-sP :进行ping扫描 (2) -sn: ping探测扫描主机, 不进行端口扫描 (3)-sA 发送ACK探测存活 端口扫描 (1) -sS :半开放扫描 (2) sT ...
- python学习21之高级特性
'''''''''1.切片(1)谁可以进行切片操作?——列表,元组,字符串(2)切片有以下几种操作'''#[a:b]:取从下标为a的元素开始,到下标为b-1的元素结束L=['aa','bb','cc' ...
- Linux分类
Linux versions:http://www.cnblogs.com/sammyliu/articles/4832157.html1. Maintained by organization- D ...
- Mobile Communication
最近面试有被问到LTE,感觉说得不太清楚,重新整理一遍. 一.第一代移动通信系统 1G,诞生于1980年左右.模拟通信系统,抗干扰性能差,使用FDMA技术,主要用来传输话音信号,最拉风的就是" ...
- 程序员最喜欢用的在线IDE代码编译器,什么?你竟然不知道!
1.网址https://tech.io/snippet 支持 20+ 种编程语言,页面上没有杂七杂八的东西,非常简约,非常干净,另外,它上面的代码段还可以嵌入到网页之中. 2.网址 https://w ...
- XML--XML从入门到精通 Part 1 认识XML
XML 指可扩展标记语言(EXtensible Markup Language) XML 是一种标记语言,很类似 HTML XML 的设计宗旨是传输数据,而非显示数据 XML 标签没有被预定义.您需要 ...
- POJ 1170 Shopping Offers非状态压缩做法
Shopping Offers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5659 Accepted: 2361 Descr ...
- 数学--数论--HDU2136 Largest prime factor 线性筛法变形
Problem Description Everybody knows any number can be combined by the prime number. Now, your task i ...
- Mybatis时间范围查询,亲测有效
Md2All export document .output_wrapper pre code{font-family: Consolas, Inconsolata, Courier, monospa ...