MySQL系列之F-2------mysqldump -help

[[email protected] ~]# mysqldump --help

mysqldump  Ver 10.13 Distrib 5.6.24, for linux-glibc2.5(x86_64)

Copyright (c) 2000, 2015, Oracle and/orits affiliates. All rights reserved.

Oracle is a registered trademark ofOracle Corporation and/or its

affiliates. Other names may betrademarks of their respective

owners.

Oracle是甲骨文公司的注册商标和/或其附属机构。

其他名称可能是其各自所有者的商标。

Dumping structure and contents of MySQLdatabases and tables.

Usage: mysqldump [OPTIONS] database[tables]

OR    mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]

OR    mysqldump [OPTIONS] --all-databases [OPTIONS]

Default options are read from thefollowing files in the given order:

/etc/my.cnf /etc/mysql/my.cnf/usr/local/mysql/etc/my.cnf ~/.my.cnf

The following groups are read:mysqldump client

The following options may be given asthe first argument:

--print-defaults        Print the program argument list andexit.

--no-defaults           Don‘t read default options from anyoption file,

except for login file.

--defaults-file=#       Only read default options from the givenfile #.

--defaults-extra-file=# Read this fileafter the global files are read.

--defaults-group-suffix=#

Also read groups withconcat(group, suffix)

--login-path=#          Read this path from the login file.

-A, --all-databases Dump all the databases. This will be same as--databases

with all databasesselected.

-Y, --all-tablespaces

Dump all the tablespaces.

-y, --no-tablespaces

Do not dump anytablespace information.

--add-drop-database Add a DROP DATABASE beforeeach create.

--add-drop-table    Add a DROPTABLE before each create.

(Defaults to on; use--skip-add-drop-table to disable.)

--add-drop-trigger  Add a DROPTRIGGER before each create.

--add-locks         Add locksaround INSERT statements.

(Defaults to on; use--skip-add-locks to disable.)

--allow-keywords    Allow creationof column names that are keywords.

--apply-slave-statements

Adds ‘STOP SLAVE‘ priorto ‘CHANGE MASTER‘ and ‘START

SLAVE‘ to bottom of dump.

--bind-address=name IP address to bind to.

--character-sets-dir=name

Directory for characterset files.

-i, --comments      Writeadditional information.

(Defaults to on; use--skip-comments to disable.)

--compatible=name   Change thedump to be compatible with a given mode. By

default tables are dumpedin a format optimized for

MySQL. Legalmodes are: ansi, mysql323, mysql40,

postgresql, oracle,mssql, db2, maxdb, no_key_options,

no_table_options,no_field_options. One can use several

modes separated bycommas. Note: Requires MySQL server

version 4.1.0 or higher.This option is ignored with

earlier server versions.

--compact           Give lessverbose output (useful for debugging). Disables

structure comments and header/footerconstructs.  Enables

options--skip-add-drop-table --skip-add-locks

--skip-comments--skip-disable-keys --skip-set-charset.

-c, --complete-insert

Use complete insert statements.

-C, --compress      Usecompression in server/client protocol.

-a, --create-options

Include all MySQLspecific create options.

(Defaults to on; use--skip-create-options to disable.)

-B, --databases     Dump severaldatabases. Note the difference in usage; in

this case no tables aregiven. All name arguments are

regarded as databasenames. ‘USE db_name;‘ will be

included in the output.

-#, --debug[=#]     This is anon-debug version. Catch this and exit.

--debug-check       Check memoryand open file usage at exit.

--debug-info        Print somedebug info at exit.

--default-character-set=name

Set thedefault character set.

--delayed-insert    Insert rowswith INSERT DELAYED.

--delete-master-logs

Delete logs on masterafter backup. This automatically

enables --master-data.

-K, --disable-keys  ‘/*!40000ALTER TABLE tb_name DISABLE KEYS */; and

‘/*!40000 ALTER TABLEtb_name ENABLE KEYS */; will be put

in the output.

(Defaults to on; use--skip-disable-keys to disable.)

--dump-slave[=#]    This causesthe binary log position and filename of the

master to be appended tothe dumped data output. Setting

the value to 1, willprintit as a CHANGE MASTER command

in the dumped data output; if equal to2, that command

will be prefixed with acomment symbol. This option will

turn --lock-all-tableson, unless --single-transaction is

specified too (in whichcase a global read lock is only

taken a short time at thebeginning of the dump - don‘t

forget to read about--single-transaction below). In all

cases any action on logswill happen at the exact moment

of the dump.Optionautomatically turns --lock-tables off.

-E, --events        Dump events.

-e, --extended-insert

Use multiple-row INSERTsyntax that include several

VALUES lists.

(Defaults to on; use--skip-extended-insert to disable.)

--fields-terminated-by=name

Fields in the output fileare terminated by the given

string.

--fields-enclosed-by=name

Fields in the output fileare enclosed by the given

character.

--fields-optionally-enclosed-by=name

Fields in the output fileare optionally enclosed by the

given character.

--fields-escaped-by=name

Fields in the output fileare escaped by the given

character.

-F, --flush-logs    Flush logsfile in server before starting dump. Note that

if you dump manydatabases at once (using the option

--databases= or--all-databases), the logs will be

flushed for each databasedumped. The exception is when

using --lock-all-tablesor --master-data: in this case

the logs will be flushedonly once, corresponding to the

moment all tables arelocked. So if you want your dump

and the log flush tohappen at the same exact moment you

should use--lock-all-tables or --master-data with

--flush-logs.

--flush-privileges  Emit a FLUSHPRIVILEGES statement after dumping the mysql

database.  This option should be used any time the dump

contains the mysqldatabase and any other database that

depends on the data inthe mysql database for proper

restore.

-f, --force         Continue evenif we get an SQL error.

-?, --help          Display this help message and exit.

--hex-blob          Dump binarystrings (BINARY, VARBINARY, BLOB) in

hexadecimal format.

-h, --host=name     Connect tohost.

--ignore-table=name Do not dump the specified table. To specify morethan one

table to ignore, use thedirective multiple times, once

for each table.  Each table must be specified with both

database and table names,e.g.,

--ignore-table=database.table.

--include-master-host-port

Adds‘MASTER_HOST=<host>, MASTER_PORT=<port>‘ to ‘CHANGE

MASTER TO..‘ in dumpproduced with --dump-slave.

--insert-ignore     Insert rows withINSERT IGNORE.

--lines-terminated-by=name

Lines in the output fileare terminated by the given

string.

-x, --lock-all-tables

Locks all tables acrossall databases. This is achieved

by taking a global readlock for the duration of the

whole dump. Automaticallyturns --single-transaction and

--lock-tables off.

-l, --lock-tables   Lock alltables for read.

(Defaults to on; use--skip-lock-tables to disable.)

--log-error=name    Appendwarnings and errors to given file.

--master-data[=#]   This causesthe binary log position and filename to be

appended to the output.If equal to 1, will print it as a

CHANGE MASTER command; ifequal to 2, that command will

be prefixed with acomment symbol. This option will turn

--lock-all-tables on,unless --single-transaction is

specified too (in whichcase a global read lock is only

taken a short time at thebeginning of the dump; don‘t

forget to read about--single-transaction below). In all

cases, any action on logs will happen at theexact moment

of the dump. Optionautomatically turns --lock-tables

off.

--max-allowed-packet=#

The maximum packet lengthto send to or receive from

server.

--net-buffer-length=#

The buffer size forTCP/IP and socket communication.

--no-autocommit     Wrap tableswith autocommit/commit statements.

-n, --no-create-db  Suppress theCREATE DATABASE ... IF EXISTS statement that

normally is output foreach dumped database if

--all-databases or--databases is given.

-t, --no-create-info

Don‘t write tablecreation info.

-d, --no-data       No rowinformation.

-N, --no-set-names  Same as--skip-set-charset.

--opt               Same as--add-drop-table, --add-locks, --create-options,

--quick,--extended-insert, --lock-tables, --set-charset,

and --disable-keys. Enabled by default,disable with

--skip-opt.

--order-by-primary  Sorts eachtable‘s rows by primary key, or first unique

key, if such a keyexists.  Useful when dumping a MyISAM

table to be loadedinto an InnoDB table, but will make

the dump itself takeconsiderably longer.

-p, --password[=name]

Password to use whenconnecting to server. If password is

not given it‘s solicited on the tty.

-P, --port=#        Port number touse for connection.

--protocol=name     The protocolto use for connection (tcp, socket, pipe,

memory).

-q, --quick         Don‘t bufferquery, dump directly to stdout.

(Defaults to on; use--skip-quick to disable.)

-Q, --quote-names   Quote tableand column names with backticks (`).

(Defaults to on; use--skip-quote-names to disable.)

--replace           Use REPLACEINTO instead of INSERT INTO.

-r, --result-file=name

Direct output to a givenfile. This option should be used

in systems (e.g., DOS,Windows) that use carriage-return

linefeed pairs (\r\n) toseparate text lines. This option

ensures that only asingle newline is used.

-R, --routines      Dump storedroutines (functions and procedures).

--set-charset       Add ‘SET NAMESdefault_character_set‘ to the output.

(Defaults to on; use--skip-set-charset to disable.)

--set-gtid-purged[=name]

Add ‘[email protected]@GLOBAL.GTID_PURGED‘ to the output. Possible

values for this optionare ON, OFF and AUTO. If ON is

used and GTIDs are notenabled on the server, an error is

generated. If OFF isused, this option does nothing. If

AUTO is used and GTIDsare enabled on the server, ‘SET

@@GLOBAL.GTID_PURGED‘ is added to theoutput. If GTIDs

are disabled, AUTO doesnothing. If no value is supplied

then the default (AUTO)value will be considered.

--single-transaction

Creates a consistent snapshot by dumping alltables in a

single transaction. WorksONLY for tables stored in

storage engines whichsupport multiversioning (currently

only InnoDB does); the dumpis NOT guaranteed to be

consistent for otherstorage engines. While a

--single-transaction dumpis in process, to ensure a

valid dump file (correcttable contents and binary log

position), no otherconnection should use the following

statements: ALTER TABLE,DROP TABLE, RENAME TABLE,

TRUNCATE TABLE, asconsistent snapshot is not isolated

from them. Optionautomatically turns off --lock-tables.

--dump-date         Put a dumpdate to the end of the output.

(Defaults to on; use--skip-dump-date to disable.)

--skip-opt          Disable --opt.Disables --add-drop-table, --add-locks,

--create-options,--quick, --extended-insert,

--lock-tables,--set-charset, and --disable-keys.

-S, --socket=name   The socketfile to use for connection.

--secure-auth       Refuse clientconnecting to server if it uses old

(pre-4.1.1) protocol.

(Defaults to on; use--skip-secure-auth to disable.)

--ssl               Enable SSL forconnection (automatically enabled with

other flags).

--ssl-ca=name       CA file in PEMformat (check OpenSSL docs, implies

--ssl).

--ssl-capath=name   CA directory(check OpenSSL docs, implies --ssl).

--ssl-cert=name     X509 cert inPEM format (implies --ssl).

--ssl-cipher=name   SSL cipher touse (implies --ssl).

--ssl-key=name      X509 key inPEM format (implies --ssl).

--ssl-crl=name      Certificaterevocation list (implies --ssl).

--ssl-crlpath=name  Certificaterevocation list path (implies --ssl).

--ssl-verify-server-cert

Verify server‘s"Common Name" in its cert against

hostname used whenconnecting. This option is disabled by

default.

-T, --tab=name      Createtab-separated textfile for each table to given

path. (Create .sql and.txt files.) NOTE: This only works

if mysqldump is run onthe same machine as the mysqld

server.

--tables            Overridesoption --databases (-B).

--triggers          Dump triggersfor each dumped table.

(Defaults to on; use--skip-triggers to disable.)

--tz-utc            SETTIME_ZONE=‘+00:00‘ at top of dump to allow dumping of

TIMESTAMP data when aserver has data in different time

zones or data is beingmoved between servers with

different time zones.

(Defaults to on; use--skip-tz-utc to disable.)

-u, --user=name     User for loginif not current user.

-v, --verbose       Print infoabout the various stages.

-V, --version       Output versioninformation and exit.

-w, --where=name    Dump onlyselected records. Quotes are mandatory.

-X, --xml           Dump adatabase as well formed XML.

--plugin-dir=name   Directory forclient-side plugins.

--default-auth=name Default authentication client-side plugin to use.

Variables (--variable-name=value)

and boolean options {FALSE|TRUE}  Value (after reading options)

-------------------------------------------------------------------------

all-databases                     FALSE

all-tablespaces                   FALSE

no-tablespaces                    FALSE

add-drop-database                 FALSE

add-drop-table                    TRUE

add-drop-trigger                  FALSE

add-locks                         TRUE

allow-keywords                    FALSE

apply-slave-statements            FALSE

bind-address                      (No default value)

character-sets-dir                (No default value)

comments                          TRUE

compatible                        (No default value)

compact                           FALSE

complete-insert                   FALSE

compress                          FALSE

create-options                    TRUE

databases                         FALSE

debug-check                       FALSE

debug-info                        FALSE

default-character-set             utf8

delayed-insert                    FALSE

delete-master-logs                FALSE

disable-keys                      TRUE

dump-slave                        0

events                            FALSE

extended-insert                   TRUE

fields-terminated-by              (No default value)

fields-enclosed-by                (No default value)

fields-optionally-enclosed-by     (No default value)

fields-escaped-by                 (No default value)

flush-logs                        FALSE

flush-privileges                  FALSE

force                             FALSE

hex-blob                          FALSE

host                              (No defaultvalue)

include-master-host-port          FALSE

insert-ignore                     FALSE

lines-terminated-by               (No default value)

lock-all-tables                   FALSE

lock-tables                       TRUE

log-error                         (No default value)

master-data                       0

max-allowed-packet                25165824

net-buffer-length                 1046528

no-autocommit                     FALSE

no-create-db                      FALSE

no-create-info                    FALSE

no-data                           FALSE

order-by-primary                  FALSE

port                              0

quick                             TRUE

quote-names                       TRUE

replace                           FALSE

routines                          FALSE

set-charset                       TRUE

single-transaction                FALSE

dump-date                         TRUE

socket                            (No default value)

secure-auth                       TRUE

ssl                               FALSE

ssl-ca                            (No default value)

ssl-capath                        (No default value)

ssl-cert                          (No default value)

ssl-cipher                        (No default value)

ssl-key                           (No default value)

ssl-crl                           (No default value)

ssl-crlpath                       (No default value)

ssl-verify-server-cert            FALSE

tab                               (No defaultvalue)

triggers                          TRUE

tz-utc                            TRUE

user                              (No defaultvalue)

verbose                           FALSE

where                             (No default value)

plugin-dir                        (No default value)

default-auth                      (No default value)

时间: 2024-12-14 18:52:49

MySQL系列之F-2------mysqldump -help的相关文章

屌炸天实战 MySQL 系列教程(四)【秒杀七年经验 LowB工程师】 主从复制、读写分离、模拟宕机、备份恢复方案生产环境实战

第一篇:屌炸天实战 MySQL 系列教程(一) 生产标准线上环境安装配置案例及棘手问题解决 第二篇:屌炸天实战 MySQL 系列教程(二) 史上最屌.你不知道的数据库操作 第三篇:屌炸天实战 MySQL 系列教程(三)你不知道的 视图.触发器.存储过程.函数.事物.索引.语句 第四篇:屌炸天实战 MySQL 系列教程(四) 主从复制.读写分离.模拟宕机.备份恢复方案生产环境实战 去年公司有一个七年PHP开发经验的工程师,想要跳槽. 去国内某知名互联网公司面试后,被虐惨了,非要我给他讲讲什么是主从

mysql系列之复制2----主从同步部署

经过了上一篇mysql系列之复制1----原理篇,相信大家已经对mysql的复制有所了解了.本篇博文将带大家一起来部署下mysql的主从同步架构. 环境: CentOS 6.5 x86_64位 采用最小化安装,系统经过了基本优化 selinux 为关闭状态,iptables 为无限制模式 主机名:master==>ip:172.16.100.1==>MySQL版本:mysql-5.5.32 主机名:slave   ==>ip:172.16.100.2==>MySQL版本:mysql

mysql 常用操作 (包括mysqldump,pt-table)

参考oldbody 全库备份 #!/bin/bash #mysqldump to fully backup mysql data if [ -f /root/.bash_profile ];then source /root/.bash_profile fi BakDir=/opt/mysqlbak/full LogFile=/opt/mysqlbak/full/bak.log Date=`date +%Y%m%d` Begin=`date +"%Y年%m月%d日 %H:%M:%S"`

mysql系列之多实例2----基于多配置文件

经过上一篇博文mysql系列之多实例1----介绍对mysql多实例进行了简单的介绍,本片博文将开始针对mysql多实例的第一种实现方案,基于多配置文件的mysql多实例进行部署实现. 环境: CentOS 6.5 x86_64位 采用最小化安装,系统经过了基本优化 selinux 为关闭状态,iptables 为无限制模式 mysql版本:mysql-5.5.38 源码包存放位置:/usr/local/src 源码包编译安装位置:/usr/local/mysql 数据库存放位置:/mydata

mysql 导入导出命令source mysqldump

几个常用用例: 1.导出整个数据库 mysqldump -u 用户名 -p 数据库名 > 导出的文件名 mysqldump -u root -p dataname >dataname.sql 这个时候会提示要你输入root用户名的密码,输入密码后dataname数据库就成功备份在mysql/bin/目录中. 2.导出一个表 mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名 mysqldump -u root -p dataname users> datanam

MySQL系列之F------MySQL备份

F.1 mysqldump的工作原理 利用mysqldump命令备份数据的过程,实际上就是把数据从mysql库里以逻辑的sql语句的形式直接输出或者生成备份文件的过程. F.2 备份 F.2.1备份单个数据库,联系多种参数使用 mysql数据库自带的备份命令mysqldump 语法:mysqldump -h数据库地址 -u用户名 -p数据库 >备份的目录和文件 范例1:备份名字为test123的库 a.查看备份前的数据 [[email protected] ~]# mysql -h 127.0.

MySQL 命令行工具之 mysqldump

mysqldump 是MySQL的一个命令行工具,用于逻辑备份.可以将数据库和表的结构,以及表中的数据分别导出成:create database, create table, insert into的sql语句.当然还可以导出 存储过程,触发器,函数,调度事件(events).不管是程序员,还是DBA都会经常使用的一个工具. 1. mysqldump --help mysqldump 的选项很多,我们看一下他的帮助: mysqldump Ver 10.13 Distrib 5.6.26, for

MySQL备份与恢复常用方法总结(mysqldump/xtrabackup/lvm快照备份/二进制日志及时点恢复)

MySQL备份与恢复常用方法总结 (mysqldump/xtrabackup/lvm快照备份/逻辑备份与恢复/二进制日志及时点恢复) 自言:学习在于总结,把所了解的类似东西放到一起更能加深记忆 一.了解备份相关知识 1)按服务器备份时状态可分为:     热备份:读.写不受影响:     温备份:仅可以执行读操作:     冷备份:离线备份:读.写操作均中止:2)按服务器备份数据集可分为:     物理备份:复制数据文件:     逻辑备份:将数据导出至文本文件中:3)按服务器备份数据量可分为:

MySQL数据备份与还原(mysqldump)

一 mysqldump指令实现数据备份.mysql指令实现数据还原 经常有朋友问我,DBA到底是做什么的,百科上说:数据库管理员(Database Administrator,简称DBA),是从事管理和维护数据库管理系统(DBMS)的相关工作人员的统称,属于运维工程师的一个分支,主要负责业务数据库从设计.测试到部署交付的全生命周期管理.DBA的核心目标是保证数据库管理系统的稳定性.安全性.完整性和高性能. 百科出来的内容总是那么的专业,让人看完之后的感觉是很解释的很好,但是我没有看懂或者似懂非懂

屌炸天实战 MySQL 系列教程(二) 史上最屌、你不知道的数据库操作

此篇写MySQL中最基础,也是最重要的操作! 第一篇:屌炸天实战 MySQL 系列教程(一) 生产标准线上环境安装配置案例及棘手问题解决 第二篇:屌炸天实战 MySQL 系列教程(二) 史上最屌.你不知道的数据库操作 本章内容: 查看\创建\使用\删除 数据库 用户管理及授权实战 局域网远程连接法 查看\创建\使用\删除\清空\修改 数据库表(是否可空,默认值,主键,自增,外键) 表内容的增删改查 where条件.通配符_%.限制limit.排序desc\asc.连表join.组合union 查