en a short time at the beginning of the dump - don't forget to read about --single-transaction below). In all cases any action on
? ? ? logs will happen at the exact moment of the dump.Option automatically turns --lock-tables off.
? ? ? --dump-slave 和 --master-data 几乎一样。区别只是--dump-slave用于slave建立下一级的slave;而 --master-data用于master建立slave;
? ? ? 如果在 master 上使用 --dump-slave 会报错:mysqldump: Couldn't execute 'START SLAVE': The server is not configured as slave;
3) --apply-slave-statements
? ? ? Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START SLAVE' to bottom of dump.
? ? ? 在 change master 导出 stop slave 语句, 在 change master 之后导出 start slave??句。其实是一个自动化的处理。和 --master-data=1 类似。
如下图所示:开头有 stop slave, 结尾有 start slave语句:


4)--include-master-host-port
? ? ? Adds 'MASTER_HOST=, MASTER_PORT=' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.
? ? ? 该选择要结合 --dump-slave=1/2 使用。会在导出中加入 host。
5)--include-master-host-port
? ? Adds 'MASTER_HOST=, MASTER_PORT=' to 'CHANGE MASTER TO..' in dump produced with --dump-slave.
? ? 该选择要结合 --dump-slave=1/2 使用。会在导出中加入mysql的 port。
6)--delete-master-logs
? ? Delete logs on master after backup. This automatically enables --master-data.
? ? 在备份之后,删除 master上的binary log。该选项会自动打开 --master-data 选项(等于2)。该选项一般不用。日志一般不能随便删除。
7)--set-gtid-purged[=name]
? ? Add 'SET @@GLOBAL.GTID_PURGED' to the output. Possible values for this option are ON, OFF and AUTO. If ON is used and GTIDs
? ? are not enabled on the server, an error is generated. If OFF is used, this option does nothing. If AUTO is used and GTIDs are enabled
? ? on the server, 'SET @@GLOBAL.GTID_PURGED' is added to the output. If GTIDs are disabled, AUTO does nothing. If no value is
? ? supplied then the default (AUTO) value will be considered.
? ? 该选项用于启用了GTID特性的环境。
6. mysqldump 字符集 的相关选项
1)--set-charset? ? ?
? ? Add 'SET NAMES default_character_set' to the output.? (Defaults to on; use --skip-set-charset to disable.)
? ? --set-charset=1/0 开启和关闭。也可以使用 --skip-set-charset 关闭。
? 该选项我们上面已经说到了。表示是否生成 /*!40101 SET NAMES utf8 */;
2)-N, --no-set-names?
? ? Same as --skip-set-charset. 关闭 --set-charset. 不生成 /*!40101 SET NAMES utf8 */; 语句。
3)--default-character-set=name
? ? Set the default character set.
? ? 该选项上面也涉及到了。指定语句:/*!40101 SET NAMES utf8 */;中的字符集;可能你需要改成 --default-character-set=utf8mb4
7. mysqldump 控制是否生成 DDL 语句 的相关选项
? --add-drop-database? Add a DROP DATABASE before each create.
? --add-drop-table? ? ? ? Add a DROP TABLE before each create.? (Defaults to on; use --skip-add-drop-table to disable.)
? --add-drop-trigger? ? ? Add a DROP TRIGGER before each create.
? --no-create-db,-n
? --no-create-info,-t
8. mysqldump 导出格式 的相关选项
1)--compatible=name?
? ? Change the dump to be compatible with a given mode. By default tables are dumped in a format optimized for MySQL.
? ? Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options,
? ? no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher.
? ? This option is ignored with earlier server versions.
? ? 导出sql语句的兼容格式。如果我们需要从MySQL导出,然后导入到其它数据库,则可使用该选项。--compatible=oracle/postgresql/mssql
2)-Q, --quote-names?
? ? Quote table and column names with backticks (`). (Defaults to on; use --skip-quote-names to disable.)
? ? 将表名和列名使用 ``包裹。以防他们是关键字时报错。
9. mysqldump 错误处理的相关选项
1)-f, --force?? ? ? ? ? ? Continue even if we get an SQL error.
2)--log-error=name? ? Append warnings and errors to given file.
10. mysqldump 实现原理
为了探求 mysqld