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 READand sends aSTART TRANSACTIONSQL 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 TRANSACTIONwas issued without blocking any applications.When using this option, you should keep in mind that only
InnoDBtables are dumped in a consistent state. For example, anyMyISAMorMEMORYtables dumped while using this option may still change state.While a
--single-transactiondump 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 theSELECTthat is performed by mysqldump to retrieve the table contents to obtain incorrect contents or fail.The
--single-transactionoption and the--lock-tablesoption are mutually exclusive becauseLOCK TABLEScauses 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
NDBCLUSTERstorage engine supports only theREAD_COMMITTEDtransaction isolation level. You should always useNDBbackup and restore instead.To dump large tables, combine the
--single-transactionoption with the--quickoption.
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 ...
随机推荐
- [Windows] 如何通过 mount point 找到对应的 VHD 文件
假设有一个 Virtual Disk(VHD) 文件.已经 online --> attach --> mount. 知道 mount 的文件夹,要找到 .vhd 文件.可以用如下方法: ...
- 非阻塞同步机制和CAS
目录 什么是非阻塞同步 悲观锁和乐观锁 CAS 非阻塞同步机制和CAS 我们知道在java 5之前同步是通过Synchronized关键字来实现的,在java 5之后,java.util.concur ...
- UVALive 7501 Business Cycle
细心题 #include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<=b;++i) # ...
- 以内存级速度实现存储?XPoint正是我们的计划
随着计算能力虚拟化技术的普及,存储机制在速度上远逊于内存这一劣势开始变得愈发凸显. 这一巨大的访问速度鸿沟一直是各项存储技术想要解决的核心难题:纸带.磁带.磁盘驱动器乃至闪存记忆体等等,而如今最新一代 ...
- CF1324F Maximum White Subtree——换根dp
换根dp,一般用来解决在无根树上,需要以每个节点为根跑一边dfs的dp问题 我们做两遍dfs 先钦定任意一个点为根 第一遍,算出\(f_i\)表示\(i\)的子树产生的答案,这里,子树指的是以我们钦定 ...
- 聊聊select, poll 和 epoll
聊聊select, poll 和 epoll 假设项目上需要实现一个TCP的客户端和服务器从而进行跨机器的数据收发,我们很可能翻阅一些资料,然后写出如下的代码. 服务端 void func(int s ...
- python-format方法记录
今天写脚本,遇到了这种情况:需要上一个脚本的回参作为一个路径参数,我用的os.path.join()处理,因为这个路径参数在最后一位,但是没有考虑到如果路径参数在中间的话,这样的拼接就只能把后面的 ...
- django-haystack全文检索详细教程
前几天要用Django-haystack来实现搜索功能,网上一搜中文资源少之又少,虽说有官方文档,但相信对于我们这些英语差的同学来说要看懂真的是一件难事.特别是关于高级部分,特地找了个英语专业的来翻译 ...
- java读源码 之 map源码分析(HashMap)二
在上篇文章中,我已经向大家介绍了HashMap的一些基础结构,相信看过文章的同学们,应该对其有一个大致了了解了,这篇文章我们继续探究它的一些内部机制,包括构造函数,字段等等~ 字段分析: // 默 ...
- 万盛酒店餐饮管理系统(SpringBoot,SSM,MySQL )
项目源码获取地址: 链接:https://pan.baidu.com/s/1ip0keQruE2crA8vm1n8ZXQ 提取码:kivb 复制这段内容后打开百度网盘手机App,操作更方便哦 [功能包 ...