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 ...
随机推荐
- 一、Go语言由来与关键时间线
Go语言,又称作Golang,是Google在2009年11月开源的开发语言.是一门静态强类型.编译型.并发型,并具有垃圾回收功能的编程语言. Go是罗伯特·格瑞史莫(Robert Griesemer ...
- Xshell下载和连接Linux
Xshell下载和连接Linux 第一步.Xshell的下载 方法1:从官网下载个人使用时免费的,商业使用是要收费的. http://www.xshellcn.com/ 方法二2:百度云下载Xshel ...
- redis部署与卸载
1.先到Redis官网(redis.io)下载redis安装包 cd /tmp wget http://download.redis.io/releases/redis-4.0.10.tar.gz 2 ...
- 【Linux常见命令】ip命令
ip命令是用来配置网卡ip信息的命令,且是未来的趋势,重启网卡后IP失效. ip - show / manipulate routing, devices, policy routing and tu ...
- Ubuntu登陆时忘记密码怎么办
有时候由于各种原因,用户会忘记自己登陆Ubuntu的登陆密码,这个时候我们能怎么办呢? 第一步:先重启电脑,开机时长按shift键,进入grub菜单: 第二步:按“e”键编辑启动项,显示如下图,将下图 ...
- SSH 超时设置
在阿里云买了一台乞丐版服务器,搭了一个博客,安装了java,mysql,redis等服务,把以前写的知乎爬虫部署上去,看看爬取效果.程序运行一段时间后,发现cmder上的日志不打了,我原以为爬虫挂了, ...
- 如何在linux服务器下快速安装配置Node.js
简单粗暴,先用xshell或其他软件连接服务器 1.下载(此处版本根据官网版本自己修改) wget https://npm.taobao.org/mirrors/node/v8.9.3/node-v8 ...
- ASP.NET Core的配置信息
ASP.NET Core的配置信息 Key-Value键值对 内存里.JSON.XML.INI等文件 配置信息与配置系统是解耦的 可以依赖注入 ASP.NET Core的配置信息来源 appsetti ...
- Spring Boot入门系列(十三)如何实现事务
前面介绍了Spring Boot 中的整合Mybatis并实现增删改查.不清楚的朋友可以看看之前的文章:https://www.cnblogs.com/zhangweizhong/category/1 ...
- Codeforces Round #577 (Div. 2) D. Treasure Hunting
Codeforces Round #577 (Div. 2) D. Treasure Hunting 这个一场div2 前面三题特别简单,这个D题的dp还是比较难的,不过题目告诉你了只能往上走,所以 ...