mysqldump -uroot -p'xxx'  -R --single-transaction --master-data=2 zjzc>$TODAY_DIR/zjzc/zjzc_${TODAY_DIR}.sql

mysqldump -uxxx -p --single-transaction --master-data=2 --routines --flush-logs --databases db1 db2 db3 > alldb.sql;

介绍下mysqldump一些备份参数:

  --routines, -R

           Include stored routines (procedures and functions) for the dumped databases in the output. Use of this
option requires the SELECT privilege for the mysql.proc table. The output generated by using --routines
contains CREATE PROCEDURE and CREATE FUNCTION statements to re-create the routines. However, these
statements do not include attributes such as the routine creation and modification timestamps. This means
that when the routines are reloaded, they will be created with the timestamps equal to the reload time. If you require routines to be re-created with their original timestamp attributes, do not use --routines.
Instead, dump and reload the contents of the mysql.proc table directly, using a MySQL account that has
appropriate privileges for the mysql database. Prior to MySQL 5.6.5, this option had no effect when used together with the --xml option. (Bug #11760384,
Bug #52792) 包含存储程序(过程和函数) 对于转储的数据库到输出,使用这个选项需要SELECT 权限对于mysql.proc表, 通过使用--routines 生成包含 CREATE PROCEDURE and CREATE FUNCTION 语句来重新创建函数。 然而,那些语句不包含属性比如函数创建和修改时间戳。 这意味着 当函数被加载时, 它们会创建使用timestamps 等于加载时间 如果你需要程序被重新创建使用它们原来的timestamp 属性,不要使用--routines --flush-logs, -F Flush the MySQL server log files before starting the dump. This option requires the RELOAD privilege. If
you use this option in combination with the --all-databases option, the logs are flushed for each
database dumped. The exception is when using --lock-all-tables, --master-data, or --single-transaction:
In this case, the logs are flushed only once, corresponding to the moment that all tables are locked. If
you want your dump and the log flush to happen at exactly the same moment, you should use --flush-logs
together with --lock-all-tables, --master-data, or --single-transaction. Flush MySQL server log files 在开始dump前, 这个选项需要RELOAD 权限。 如果你使用这个选项 结合--all-databases option, 日志是刷新为每个数据库转储 例外是当使用 using --lock-all-tables, --master-data, or --single-transaction: 在这种情况下, logs只刷新一次,对应的时间点 所有的表被锁住 如果你需要你的dump和log flush 发生在同一个事件点,你需要使用--flush-logs
together with --lock-all-tables, --master-data, or --single-transaction. --single-transaction 这个选项设置事务隔离级别为 REPEATABLE READ 发送一个START TRANSACTION SQL语句到服务器在开始dump数据前. 它只对于transactional tables 比如InnoDB是有用的 因为然后它备份数据库的一致性状态在START TRANSACTION被执行后 不会堵塞其他应用 当使用这个选项,你需要记录只有InnoDB 表是备份成一致性状态的 对于 MyISAM or MEMORY 表备份当使用这个选项时 仍旧会改变状态 当使用一个 --single-transaction 来处理,确保一个正确的dump文件(正确的表内容和binary log coordinates(坐标)) 没有其他的连接使用下面的语句: ALTER TABLE, CREATE
TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE 一个一致性读是不能和那些语句分离的。 因此使用它们在一个表准备被dump 可能导致SELECT 被执行通过MYSQLDUMP 来检索表内存得到不正确的内容或者失败 --single-transaction 选项和e --lock-tables 选项是相互排斥的 因为LOCK TABLES 导致任何pending transactions被隐式的提交 · --master-data[=value] Use this option to dump a master replication server to produce a dump file that can be used to set up
another server as a slave of the master. It causes the dump output to include a CHANGE MASTER TO
statement that indicates the binary log coordinates (file name and position) of the dumped server. These
are the master server coordinates from which the slave should start replicating after you load the dump
file into the slave. If the option value is 2, the CHANGE MASTER TO statement is written as an SQL comment, and thus is
informative only; it has no effect when the dump file is reloaded. If the option value is 1, the
statement is not written as a comment and takes effect when the dump file is reloaded. If no option value
is specified, the default value is 1. This option requires the RELOAD privilege and the binary log must be enabled. The --master-data option automatically turns off --lock-tables. It also turns on --lock-all-tables,
unless --single-transaction also is specified, in which case, a global read lock is acquired only for a
short time at the beginning of the dump (see the description for --single-transaction). In all cases, any
action on logs happens at the exact moment of the dump. It is also possible to set up a slave by dumping an existing slave of the master, using the --dump-slave
option, which overrides --master-data and causes it to be ignored if both options are used. Prior to MySQL 5.6.4, this option was required for dumping the replication log tables (see
Section 17.2.2, “Replication Relay and Status Logs”). 使用这个选项 来dump一个master 复制server 来产生一个dump 文件可以用于设置另外的server 作为master的一个slave. 它可以让dump 输出包含一个CHANGE MASTER TO 语句表明binary log coordinates (文件和位置) 这些是master server 的坐标 slave 应该开始复制在加载dump文件到slave后。 如果选项的值是2, CHANGE MASTER TO 语句是写成一个SQL注释,因此 只是提供信息的, 没有影响当dump 文件被加载时。 如果选项是1, 语句不是写成注释,当dump 文件被加载时是生效的 如果选项没有指定值,默认是1 这个选项需要RELOAD 权限和binary log 必须启用 --master-data 选项会自动的关闭 --lock-tables. 它也开启--lock-all-tables, 除非你指定 --single-transaction 在这种情况下,一个 global read lock是需要的在dumo开始的短暂时间内 它也可以用于设置一个slave 通过dump 一个存在的master的slave,使用 --dump-slave选项,

mysqldump 一些参数体验的更多相关文章

  1. mysqldump主要参数探究

    在数据库的日常维护中,对于数据量小的备份,我们常常采用的是逻辑备份,也就是使用mysqldump导出.数据量比较大的备份会使用percona的xtrabackup,关于xtrabackup工具的使用以 ...

  2. mysqldump默认参数add-drop-table

    mysqldump默认参数add-drop-table 原创 2014年01月28日 11:35:18 9214 接到一个同事电话,说UAT环境上的一张表被删了,要恢复一下.原来是新项目UAT,从测试 ...

  3. mysqldump常用参数

    mysqldump常用参数说明  --all-databases 或 -A  导出全部数据库.--all-tablespaces 或 -Y 导出全部表空间--no-tablespaces  或 -y ...

  4. 数据库备份工具mysqldump重要参数详解

    1. --single-transaction InnoDB 表在备份时,通常启用选项 --single-transaction 来保证备份的一致性,实际上它的工作原理是设定本次会话的隔离级别为:RE ...

  5. mysqldump 逻辑备份的正确姿势

    在上一篇文章 MySQL 命令行工具之 mysqldump 深入研究 中,我们搞定了mysqldump的参数和基本原理.那么我们该怎么样最好的使用它的?它有哪些坑呢? 1. 利用mysqldump进行 ...

  6. Mysqldump源码分析

    版权声明:本文由王珏原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/261 来源:腾云阁 https://www.qclou ...

  7. Mysql导入导出工具Mysqldump和Source命令用法详解

    Mysql本身提供了命令行导出工具Mysqldump和Mysql Source导入命令进行SQL数据导入导出工作,通过Mysql命令行导出工具Mysqldump命令能够将Mysql数据导出为文本格式( ...

  8. Mysql备份--mysqldump&outfile

    1.备份工具mysqldump 客户端和服务器端都能用select outfile 只能写到服务器端 2.按表单位备份 a.单个表备份 mysqldump -uusername -p database ...

  9. [转]Mysql导入导出工具Mysqldump和Source命令用法详解

    Mysql本身提供了命令行导出工具Mysqldump和Mysql Source导入命令进行SQL数据导入导出工作,通过Mysql命令行导出工具Mysqldump命令能够将Mysql数据导出为文本格式( ...

随机推荐

  1. 如何下载coursera视频

    国内观看Coursera非常卡顿,经常播放到一半就卡死了,不知道什么原因.因此只能想办法下载下来之后再看. Github上有一个脚本点击打开链接,提供整门课程的下载服务.用着还是非常方便的,使用方法如 ...

  2. WebChat 清爽来袭 -- JavaChat系统Ⅳ

    题记:          WebChat 依然搭配的是 JavaChat 服务器,在不修改原来服务器代码的情况下进行使用终端的扩展.         此次项目的难点在于,Action/Servlet ...

  3. 再探java基础——对面向对象的理解(2)

    对象.类和抽象类的区别 对象是一个具体的事物,类是对具有相同属性和行为的一组对象的抽象,对象是类的一个一个人的具体实例:抽象类是一种特殊的类,是对类的进一步抽象,抽象类不能被实例化. 类.抽象类和接口 ...

  4. Android 开源项目android-open-project解析之(三) ScrollView,TimeView,TipView,FlipView

    九.ScrollView Discrollview 支持滚动时Item淡入淡出,平移,缩放效果的ScrollView 项目地址:https://github.com/flavienlaurent/di ...

  5. C++笔试题库-------Coding整理

    1. 反转字符串 char* strrev1(const char* str) { int len = strlen(str); ]; char *p = temp + len; *p = '\0'; ...

  6. CoreText实现图文混排之点击事件

    今天呢,我们继续把CoreText图文混排的点击事件补充上,这样我们的图文混排也算是圆满了. 哦,上一篇的链接在这里 http://www.jianshu.com/p/6db3289fb05d Cor ...

  7. [转]Vim 复制粘帖格式错乱问题的解决办法

    有时候,复制文本(尤其是代码)到 Vim,会出现格式错乱的问题.看样子,应该是自动缩进惹得祸.本文不去深究原因,直接给出解决方法. 1. paste 模式 运行如下命令,进入 paste 模式: :s ...

  8. 最小圆覆盖 hdu 3007

    今天学习了一下最小圆覆盖, 看了一下午都没看懂, 晚上慢慢的摸索这代码,接合着别人的讲解, 画着图跟着代码一步一步的走着,竟然有些理解了. 最小圆覆盖: 给定n个点, 求出半径最小的圆可以把这些点全部 ...

  9. Day9 - Python 多线程、进程

    Python之路,Day9, 进程.线程.协程篇   本节内容 操作系统发展史介绍 进程.与线程区别 python GIL全局解释器锁 线程 语法 join 线程锁之Lock\Rlock\信号量 将线 ...

  10. Angular JS API

    ng function angular.bind angular.bootstrap angular.copy angular.element angular.equals angular.exten ...