运维联盟俱乐部

 找回密码
 立即注册
查看: 6454|回复: 0

[日常管理] command-mysqldump

[复制链接]
  • TA的每日心情
    开心
    2023-8-9 11:05
  • 发表于 2022-1-20 13:19:43 | 显示全部楼层 |阅读模式

    1. [root@vm1 bin]# ./mysqldump --help
    2. mysqldump  Ver 8.0.27 for Linux on x86_64 (MySQL Community Server - GPL)
    3. Copyright (c) 2000, 2021, Oracle and/or its affiliates.

    4. Oracle is a registered trademark of Oracle Corporation and/or its
    5. affiliates. Other names may be trademarks of their respective
    6. owners.

    7. Dumping structure and contents of MySQL databases and tables.
    8. Usage: mysqldump [OPTIONS] database [tables]
    9. OR     mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...]
    10. OR     mysqldump [OPTIONS] --all-databases [OPTIONS]

    11. Default options are read from the following files in the given order:
    12. /etc/my.cnf /etc/mysql/my.cnf /usr/local/mysql/etc/my.cnf ~/.my.cnf
    13. The following groups are read: mysqldump client
    14. The following options may be given as the first argument:
    15. --print-defaults        Print the program argument list and exit.
    16. --no-defaults           Don't read default options from any option file,
    17.                         except for login file.
    18. --defaults-file=#       Only read default options from the given file #.
    19. --defaults-extra-file=# Read this file after the global files are read.
    20. --defaults-group-suffix=#
    21.                         Also read groups with concat(group, suffix)
    22. --login-path=#          Read this path from the login file.
    23.   -A, --all-databases Dump all the databases. This will be same as --databases
    24.                       with all databases selected.
    25.   -Y, --all-tablespaces
    26.                       Dump all the tablespaces.
    27.   -y, --no-tablespaces
    28.                       Do not dump any tablespace information.
    29.   --add-drop-database Add a DROP DATABASE before each create.
    30.   --add-drop-table    Add a DROP TABLE before each create.
    31.                       (Defaults to on; use --skip-add-drop-table to disable.)
    32.   --add-drop-trigger  Add a DROP TRIGGER before each create.
    33.   --add-locks         Add locks around INSERT statements.
    34.                       (Defaults to on; use --skip-add-locks to disable.)
    35.   --allow-keywords    Allow creation of column names that are keywords.
    36.   --apply-replica-statements
    37.                       Adds 'STOP SLAVE' prior to 'CHANGE MASTER' and 'START
    38.                       SLAVE' to bottom of dump.
    39.   --apply-slave-statements
    40.                       This option is deprecated and will be removed in a future
    41.                       version. Use apply-replica-statements instead.
    42.   --bind-address=name IP address to bind to.
    43.   --character-sets-dir=name
    44.                       Directory for character set files.
    45.   --column-statistics Add an ANALYZE TABLE statement to regenerate any existing
    46.                       column statistics.
    47.                       (Defaults to on; use --skip-column-statistics to disable.)
    48.   -i, --comments      Write additional information.
    49.                       (Defaults to on; use --skip-comments to disable.)
    50.   --compatible=name   Change the dump to be compatible with a given mode. By
    51.                       default tables are dumped in a format optimized for
    52.                       MySQL. The only legal mode is ANSI.Note: Requires MySQL
    53.                       server version 4.1.0 or higher. This option is ignored
    54.                       with earlier server versions.
    55.   --compact           Give less verbose output (useful for debugging). Disables
    56.                       structure comments and header/footer constructs.  Enables
    57.                       options --skip-add-drop-table --skip-add-locks
    58.                       --skip-comments --skip-disable-keys --skip-set-charset.
    59.   -c, --complete-insert
    60.                       Use complete insert statements.
    61.   -C, --compress      Use compression in server/client protocol.
    62.   -a, --create-options
    63.                       Include all MySQL specific create options.
    64.                       (Defaults to on; use --skip-create-options to disable.)
    65.   -B, --databases     Dump several databases. Note the difference in usage; in
    66.                       this case no tables are given. All name arguments are
    67.                       regarded as database names. 'USE db_name;' will be
    68.                       included in the output.
    69.   -#, --debug[=#]     This is a non-debug version. Catch this and exit.
    70.   --debug-check       This is a non-debug version. Catch this and exit.
    71.   --debug-info        This is a non-debug version. Catch this and exit.
    72.   --default-character-set=name
    73.                       Set the default character set.
    74.   --delete-source-logs
    75.                       Rotate logs before the backup, equivalent to FLUSH LOGS,
    76.                       and purge all old binary logs after the backup,
    77.                       equivalent to PURGE LOGS. This automatically enables
    78.                       --source-data.
    79.   --delete-master-logs
    80.                       This option is deprecated and will be removed in a future
    81.                       version. Use delete-source-logs instead.
    82.   -K, --disable-keys  '/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and
    83.                       '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put
    84.                       in the output.
    85.                       (Defaults to on; use --skip-disable-keys to disable.)
    86.   --dump-replica[=#]  This causes the binary log position and filename of the
    87.                       source to be appended to the dumped data output. Setting
    88.                       the value to 1, will printit as a CHANGE MASTER command
    89.                       in the dumped data output; if equal to 2, that command
    90.                       will be prefixed with a comment symbol. This option will
    91.                       turn --lock-all-tables on, unless --single-transaction is
    92.                       specified too (in which case a global read lock is only
    93.                       taken a short time at the beginning of the dump - don't
    94.                       forget to read about --single-transaction below). In all
    95.                       cases any action on logs will happen at the exact moment
    96.                       of the dump.Option automatically turns --lock-tables off.
    97.   --dump-slave[=#]    This option is deprecated and will be removed in a future
    98.                       version. Use dump-replica instead.
    99.   -E, --events        Dump events.
    100.   -e, --extended-insert
    101.                       Use multiple-row INSERT syntax that include several
    102.                       VALUES lists.
    103.                       (Defaults to on; use --skip-extended-insert to disable.)
    104.   --fields-terminated-by=name
    105.                       Fields in the output file are terminated by the given
    106.                       string.
    107.   --fields-enclosed-by=name
    108.                       Fields in the output file are enclosed by the given
    109.                       character.
    110.   --fields-optionally-enclosed-by=name
    111.                       Fields in the output file are optionally enclosed by the
    112.                       given character.
    113.   --fields-escaped-by=name
    114.                       Fields in the output file are escaped by the given
    115.                       character.
    116.   -F, --flush-logs    Flush logs file in server before starting dump. Note that
    117.                       if you dump many databases at once (using the option
    118.                       --databases= or --all-databases), the logs will be
    119.                       flushed for each database dumped. The exception is when
    120.                       using --lock-all-tables or --source-data: in this case
    121.                       the logs will be flushed only once, corresponding to the
    122.                       moment all tables are locked. So if you want your dump
    123.                       and the log flush to happen at the same exact moment you
    124.                       should use --lock-all-tables or --source-data with
    125.                       --flush-logs.
    126.   --flush-privileges  Emit a FLUSH PRIVILEGES statement after dumping the mysql
    127.                       database.  This option should be used any time the dump
    128.                       contains the mysql database and any other database that
    129.                       depends on the data in the mysql database for proper
    130.                       restore.
    131.   -f, --force         Continue even if we get an SQL error.
    132.   -?, --help          Display this help message and exit.
    133.   --hex-blob          Dump binary strings (BINARY, VARBINARY, BLOB) in
    134.                       hexadecimal format.
    135.   -h, --host=name     Connect to host.
    136.   --ignore-error=name A comma-separated list of error numbers to be ignored if
    137.                       encountered during dump.
    138.   --ignore-table=name Do not dump the specified table. To specify more than one
    139.                       table to ignore, use the directive multiple times, once
    140.                       for each table.  Each table must be specified with both
    141.                       database and table names, e.g.,
    142.                       --ignore-table=database.table.
    143.   --include-source-host-port
    144.                       Adds 'MASTER_HOST=<host>, MASTER_PORT=<port>' to 'CHANGE
    145.                       MASTER TO..' in dump produced with --dump-replica.
    146.   --include-master-host-port
    147.                       This option is deprecated and will be removed in a future
    148.                       version. Use include-source-host-port instead.
    149.   --insert-ignore     Insert rows with INSERT IGNORE.
    150.   --lines-terminated-by=name
    151.                       Lines in the output file are terminated by the given
    152.                       string.
    153.   -x, --lock-all-tables
    154.                       Locks all tables across all databases. This is achieved
    155.                       by taking a global read lock for the duration of the
    156.                       whole dump. Automatically turns --single-transaction and
    157.                       --lock-tables off.
    158.   -l, --lock-tables   Lock all tables for read.
    159.                       (Defaults to on; use --skip-lock-tables to disable.)
    160.   --log-error=name    Append warnings and errors to given file.
    161.   --source-data[=#]   This causes the binary log position and filename to be
    162.                       appended to the output. If equal to 1, will print it as a
    163.                       CHANGE MASTER command; if equal to 2, that command will
    164.                       be prefixed with a comment symbol. This option will turn
    165.                       --lock-all-tables on, unless --single-transaction is
    166.                       specified too (in which case a global read lock is only
    167.                       taken a short time at the beginning of the dump; don't
    168.                       forget to read about --single-transaction below). In all
    169.                       cases, any action on logs will happen at the exact moment
    170.                       of the dump. Option automatically turns --lock-tables
    171.                       off.
    172.   --master-data[=#]   This option is deprecated and will be removed in a future
    173.                       version. Use source-data instead.
    174.   --max-allowed-packet=#
    175.                       The maximum packet length to send to or receive from
    176.                       server.
    177.   --net-buffer-length=#
    178.                       The buffer size for TCP/IP and socket communication.
    179.   --no-autocommit     Wrap tables with autocommit/commit statements.
    180.   -n, --no-create-db  Suppress the CREATE DATABASE ... IF EXISTS statement that
    181.                       normally is output for each dumped database if
    182.                       --all-databases or --databases is given.
    183.   -t, --no-create-info
    184.                       Don't write table creation info.
    185.   -d, --no-data       No row information.
    186.   -N, --no-set-names  Same as --skip-set-charset.
    187.   --opt               Same as --add-drop-table, --add-locks, --create-options,
    188.                       --quick, --extended-insert, --lock-tables, --set-charset,
    189.                       and --disable-keys. Enabled by default, disable with
    190.                       --skip-opt.
    191.   --order-by-primary  Sorts each table's rows by primary key, or first unique
    192.                       key, if such a key exists.  Useful when dumping a MyISAM
    193.                       table to be loaded into an InnoDB table, but will make
    194.                       the dump itself take considerably longer.
    195.   -p, --password[=name]
    196.                       Password to use when connecting to server. If password is
    197.                       not given it's asked from the tty.
    198.   -,, --password1[=name]
    199.                       Password for first factor authentication plugin.
    200.   -,, --password2[=name]
    201.                       Password for second factor authentication plugin.
    202.   -,, --password3[=name]
    203.                       Password for third factor authentication plugin.
    204.   -P, --port=#        Port number to use for connection.
    205.   --protocol=name     The protocol to use for connection (tcp, socket, pipe,
    206.                       memory).
    207.   -q, --quick         Don't buffer query, dump directly to stdout.
    208.                       (Defaults to on; use --skip-quick to disable.)
    209.   -Q, --quote-names   Quote table and column names with backticks (`).
    210.                       (Defaults to on; use --skip-quote-names to disable.)
    211.   --replace           Use REPLACE INTO instead of INSERT INTO.
    212.   -r, --result-file=name
    213.                       Direct output to a given file. This option should be used
    214.                       in systems (e.g., DOS, Windows) that use carriage-return
    215.                       linefeed pairs (\r\n) to separate text lines. This option
    216.                       ensures that only a single newline is used.
    217.   -R, --routines      Dump stored routines (functions and procedures).
    218.   --set-charset       Add 'SET NAMES default_character_set' to the output.
    219.                       (Defaults to on; use --skip-set-charset to disable.)
    220.   --set-gtid-purged[=name]
    221.                       Add 'SET @@GLOBAL.GTID_PURGED' to the output. Possible
    222.                       values for this option are ON, COMMENTED, OFF and AUTO.
    223.                       If ON is used and GTIDs are not enabled on the server, an
    224.                       error is generated. If COMMENTED is used, 'SET
    225.                       @@GLOBAL.GTID_PURGED' is added as a comment. If OFF is
    226.                       used, this option does nothing. If AUTO is used and GTIDs
    227.                       are enabled on the server, 'SET @@GLOBAL.GTID_PURGED' is
    228.                       added to the output. If GTIDs are disabled, AUTO does
    229.                       nothing. If no value is supplied then the default (AUTO)
    230.                       value will be considered.
    231.   --single-transaction
    232.                       Creates a consistent snapshot by dumping all tables in a
    233.                       single transaction. Works ONLY for tables stored in
    234.                       storage engines which support multiversioning (currently
    235.                       only InnoDB does); the dump is NOT guaranteed to be
    236.                       consistent for other storage engines. While a
    237.                       --single-transaction dump is in process, to ensure a
    238.                       valid dump file (correct table contents and binary log
    239.                       position), no other connection should use the following
    240.                       statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
    241.                       TRUNCATE TABLE, as consistent snapshot is not isolated
    242.                       from them. Option automatically turns off --lock-tables.
    243.   --dump-date         Put a dump date to the end of the output.
    244.                       (Defaults to on; use --skip-dump-date to disable.)
    245.   --skip-opt          Disable --opt. Disables --add-drop-table, --add-locks,
    246.                       --create-options, --quick, --extended-insert,
    247.                       --lock-tables, --set-charset, and --disable-keys.
    248.   -S, --socket=name   The socket file to use for connection.
    249.   --server-public-key-path=name
    250.                       File path to the server public RSA key in PEM format.
    251.   --get-server-public-key
    252.                       Get server public key
    253.   --ssl-mode=name     SSL connection mode.
    254.   --ssl-ca=name       CA file in PEM format.
    255.   --ssl-capath=name   CA directory.
    256.   --ssl-cert=name     X509 cert in PEM format.
    257.   --ssl-cipher=name   SSL cipher to use.
    258.   --ssl-key=name      X509 key in PEM format.
    259.   --ssl-crl=name      Certificate revocation list.
    260.   --ssl-crlpath=name  Certificate revocation list path.
    261.   --tls-version=name  TLS version to use, permitted values are: TLSv1, TLSv1.1,
    262.                       TLSv1.2, TLSv1.3
    263.   --ssl-fips-mode=name
    264.                       SSL FIPS mode (applies only for OpenSSL); permitted
    265.                       values are: OFF, ON, STRICT
    266.   --tls-ciphersuites=name
    267.                       TLS v1.3 cipher to use.
    268.   -T, --tab=name      Create tab-separated textfile for each table to given
    269.                       path. (Create .sql and .txt files.) NOTE: This only works
    270.                       if mysqldump is run on the same machine as the mysqld
    271.                       server.
    272.   --tables            Overrides option --databases (-B).
    273.   --triggers          Dump triggers for each dumped table.
    274.                       (Defaults to on; use --skip-triggers to disable.)
    275.   --tz-utc            SET TIME_ZONE='+00:00' at top of dump to allow dumping of
    276.                       TIMESTAMP data when a server has data in different time
    277.                       zones or data is being moved between servers with
    278.                       different time zones.
    279.                       (Defaults to on; use --skip-tz-utc to disable.)
    280.   -u, --user=name     User for login if not current user.
    281.   -v, --verbose       Print info about the various stages.
    282.   -V, --version       Output version information and exit.
    283.   -w, --where=name    Dump only selected records. Quotes are mandatory.
    284.   -X, --xml           Dump a database as well formed XML.
    285.   --plugin-dir=name   Directory for client-side plugins.
    286.   --default-auth=name Default authentication client-side plugin to use.
    287.   --enable-cleartext-plugin
    288.                       Enable/disable the clear text authentication plugin.
    289.   -M, --network-timeout
    290.                       Allows huge tables to be dumped by setting
    291.                       max_allowed_packet to maximum value and
    292.                       net_read_timeout/net_write_timeout to large value.
    293.                       (Defaults to on; use --skip-network-timeout to disable.)
    294.   --show-create-table-skip-secondary-engine
    295.                       Controls whether SECONDARY_ENGINE CREATE TABLE clause
    296.                       should be dumped or not. No effect on older servers that
    297.                       do not support the server side option.
    298.   --compression-algorithms=name
    299.                       Use compression algorithm in server/client protocol.
    300.                       Valid values are any combination of
    301.                       'zstd','zlib','uncompressed'.
    302.   --zstd-compression-level=#
    303.                       Use this compression level in the client/server protocol,
    304.                       in case --compression-algorithms=zstd. Valid range is
    305.                       between 1 and 22, inclusive. Default is 3.

    306. Variables (--variable-name=value)
    307. and boolean options {FALSE|TRUE}        Value (after reading options)
    308. --------------------------------------- ----------------------------------
    309. all-databases                           FALSE
    310. all-tablespaces                         FALSE
    311. no-tablespaces                          FALSE
    312. add-drop-database                       FALSE
    313. add-drop-table                          TRUE
    314. add-drop-trigger                        FALSE
    315. add-locks                               TRUE
    316. allow-keywords                          FALSE
    317. apply-replica-statements                FALSE
    318. apply-slave-statements                  FALSE
    319. bind-address                            (No default value)
    320. character-sets-dir                      (No default value)
    321. column-statistics                       TRUE
    322. comments                                TRUE
    323. compatible                              (No default value)
    324. compact                                 FALSE
    325. complete-insert                         FALSE
    326. compress                                FALSE
    327. create-options                          TRUE
    328. databases                               FALSE
    329. default-character-set                   utf8mb4
    330. delete-source-logs                      FALSE
    331. delete-master-logs                      FALSE
    332. disable-keys                            TRUE
    333. dump-replica                            0
    334. dump-slave                              0
    335. events                                  FALSE
    336. extended-insert                         TRUE
    337. fields-terminated-by                    (No default value)
    338. fields-enclosed-by                      (No default value)
    339. fields-optionally-enclosed-by           (No default value)
    340. fields-escaped-by                       (No default value)
    341. flush-logs                              FALSE
    342. flush-privileges                        FALSE
    343. force                                   FALSE
    344. hex-blob                                FALSE
    345. host                                    (No default value)
    346. ignore-error                            (No default value)
    347. include-source-host-port                FALSE
    348. include-master-host-port                FALSE
    349. insert-ignore                           FALSE
    350. lines-terminated-by                     (No default value)
    351. lock-all-tables                         FALSE
    352. lock-tables                             TRUE
    353. log-error                               (No default value)
    354. source-data                             0
    355. master-data                             0
    356. max-allowed-packet                      25165824
    357. net-buffer-length                       1046528
    358. no-autocommit                           FALSE
    359. no-create-db                            FALSE
    360. no-create-info                          FALSE
    361. no-data                                 FALSE
    362. order-by-primary                        FALSE
    363. port                                    0
    364. quick                                   TRUE
    365. quote-names                             TRUE
    366. replace                                 FALSE
    367. routines                                FALSE
    368. set-charset                             TRUE
    369. single-transaction                      FALSE
    370. dump-date                               TRUE
    371. socket                                  (No default value)
    372. server-public-key-path                  (No default value)
    373. get-server-public-key                   FALSE
    374. ssl-ca                                  (No default value)
    375. ssl-capath                              (No default value)
    376. ssl-cert                                (No default value)
    377. ssl-cipher                              (No default value)
    378. ssl-key                                 (No default value)
    379. ssl-crl                                 (No default value)
    380. ssl-crlpath                             (No default value)
    381. tls-version                             (No default value)
    382. tls-ciphersuites                        (No default value)
    383. tab                                     (No default value)
    384. triggers                                TRUE
    385. tz-utc                                  TRUE
    386. user                                    (No default value)
    387. verbose                                 FALSE
    388. where                                   (No default value)
    389. plugin-dir                              (No default value)
    390. default-auth                            (No default value)
    391. enable-cleartext-plugin                 FALSE
    392. network-timeout                         TRUE
    393. show-create-table-skip-secondary-engine FALSE
    394. compression-algorithms                  (No default value)
    395. zstd-compression-level                  3
    复制代码



    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    运维联盟俱乐部 ( 冀ICP备19036648号 )

    GMT+8, 2024-5-12 15:16 , Processed in 0.075847 second(s), 22 queries , Gzip On.

    Powered by Discuz! X3.4

    © 2001-2023 Discuz! Team.

    快速回复 返回顶部 返回列表