mysql backup

--all-databases , -A
Export all databases.
mysqldump -uroot -p --all-databases
--all-tablespaces , -Y
exports all tablespaces.
mysqldump -uroot -p --all-databases --all-tablespaces
--no-tablespaces , -y
does not export any tablespace information.
mysqldump -uroot -p --all-databases --no-tablespaces
--add-drop-database
Add a drop database statement before each database is created.
mysqldump -uroot -p --all-databases --add-drop-database
--add-drop-table
Add a drop data table statement before each data table is created. (Open by default, use --skip-add-drop-table to cancel the option)
mysqldump -uroot -p --all-databases (add drop statement by default)
mysqldump -uroot -p --all-databases --skip-add- drop-table (cancel drop statement)
--add-locks
Increment LOCK TABLES before each table export and UNLOCK TABLE after. (Open by default, use --skip-add-locks to cancel the option)
mysqldump -uroot -p --all-databases (default LOCK statement is added)
mysqldump -uroot -p --all-databases --skip-add-locks ( Cancel the LOCK statement)
--allow-keywords
allows to create column names that are keywords. This is done by prefixing each column name with the table name.
mysqldump -uroot -p --all-databases --allow-keywords
--apply-slave-statements
add 'STOP SLAVE' before 'CHANGE MASTER' and 'START SLAVE' at the end of the export.
mysqldump -uroot -p --all-databases --apply-slave-statements
--character-sets-dir
Directory for character set files
mysqldump -uroot -p --all-databases --character-sets-dir=/usr/ local/mysql/share/mysql/charsets
--comments
Additional comment information. The default is open, you can use --skip-comments to cancel
mysqldump -uroot -p --all-databases (default record comments)
mysqldump -uroot -p --all-databases --skip-comments (uncomment)
--compatible The
exported data will be compatible with other databases or older versions of MySQL. Values ​​can be ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_tables_options, no_field_options, etc.
To use several values, separate them with commas. It does not guarantee complete compatibility, but is as compatible as possible.
mysqldump -uroot -p --all-databases --compatible=ansi --compact
exports
less output information (for debugging). Remove comments and structures such as headers and tails. Options available: --skip-add-drop-table --skip-add-locks --skip-comments --skip-disable-keys
mysqldump -uroot -p --all-databases
--compact --complete-insert , -c
use the full insert statement (including column names). Doing so can improve the insertion efficiency, but may be affected by the max_allowed_packet parameter and cause the insertion to fail.
mysqldump -uroot -p --all-databases --complete-insert
--compress, -C
enables compression to pass all information between client and server
mysqldump -uroot -p --all-databases --compress
--create-options, -a
Include all MySQL feature options in the CREATE TABLE statement. (Open by default)
mysqldump -uroot -p --all-databases --databases
, -B
exports several databases. All name parameters following the parameter are treated as database names.
mysqldump -uroot -p --databases test mysql
--debug
Output debug information for debugging. The default value is: d:t,/tmp/mysqldump.trace
mysqldump -uroot -p --all-databases --debug
mysqldump -uroot -p --all-databases --debug=” d:t,/tmp/debug .trace"
--debug-check
check memory and open file usage instructions and exit.
mysqldump -uroot -p --all-databases --debug-check
--debug-info
output debug information and exit
mysqldump -uroot -p --all-databases --debug-info
--default-character-set
set default characters set, default is utf8
mysqldump -uroot -p --all-databases --default-character-set=utf8
--delayed-insert
uses delayed insertion mode (INSERT DELAYED) to export data
mysqldump -uroot -p --all-databases --delayed-insert
--delete-master-logs
Delete logs after master backup. This parameter will automatically activate --master-data.
mysqldump -uroot -p --all-databases --delete-master-logs
--disable-keys
For each table, use /*!40000 ALTER TABLE tbl_name DISABLE KEYS */; and /*!40000 ALTER TABLE tbl_name ENABLE KEYS The */; statement refers to the INSERT statement. This makes importing the dumped file faster because it creates the index after all rows have been inserted. This option only applies to MyISAM tables and is turned on by default.
mysqldump -uroot -p --all-databases
--dump-slave
This option appends the master's binlog location and filename to the exported data file (show slave status). When set to 1, it will be output to the data file with the CHANGE MASTER command; when set to 2, a comment will be added before the change. This option will turn on --lock-all-tables unless --single-transaction is specified. This option automatically turns off the --lock-tables option. The default value is 0.
mysqldump -uroot -p --all-databases --dump-slave=1
mysqldump -uroot -p --all-databases --dump-slave=2 --master-
data name is appended to the output file (show master status). If it is 1, it will output the CHANGE MASTER command; if it is 2, add comment information before the output CHANGE MASTER command. This option will turn on the --lock-all-tables option unless --single-transaction is also specified (in which case the global read lock is acquired for a short time at the start of the export; see --single below for other details -transaction option). This option automatically turns off the --lock-tables option.
mysqldump -uroot -p --host=localhost --all-databases --master-data=1;
mysqldump -uroot -p --host=localhost --all-databases --master-data=2; --events, -E
Export events.
mysqldump -uroot -p --all-databases --events
--extended-insert, -e
Use INSERT syntax with multiple VALUES columns. This makes the export file smaller and speeds up the import. On by default, use the --skip-extended-insert option to cancel.
mysqldump -uroot -p --all-databases
mysqldump -uroot -p --all-databases--skip-extended-insert (unoptions)
--fields-terminated-by
Ignore the given fields in the exported file. Used with the --tab option, cannot be used with the --databases and --all-databases options
mysqldump -uroot -p test test --tab=”/home/mysql” --fields-terminated-by=”#”
- -fields-enclosed-by
The fields in the output file are wrapped with the given characters. Used with the --tab option, cannot be used with the --databases and --all-databases options
mysqldump -uroot -p test test --tab=”/home/mysql” --fields-enclosed-by=”#”
- -fields-optionally-enclosed-by
Optionally wrap fields in the output file with the given characters. Used with the --tab option, cannot be used with the --databases and --all-databases options
mysqldump -uroot -p test test --tab=”/home/mysql” --fields-enclosed-by=”#” --fields-optionally-enclosed-by=”#”
--fields-escaped-by
output file The individual fields in ignore the given characters. Used with the --tab option, cannot be used with the --databases and --all-databases options
mysqldump -uroot -p mysql user --tab=”/home/mysql” --fields-escaped-by=”#”
- -flush-logs
Flush logs before starting export.
Please note: If multiple databases are exported at once (with option --databases or --all-databases), the log will be flushed database by database. Except using --lock-all-tables or --master-data. In this case, the log will be flushed once, and the corresponding table will be locked at the same time. Therefore, if you intend to export and flush logs at the same time, you should use --lock-all-tables or --master-data and --flush-logs.
mysqldump -uroot -p --all-databases --flush-logs
--flush-privileges
Issue a FLUSH PRIVILEGES statement after exporting the mysql database. For proper recovery, this option should be used whenever exporting mysql database and data that depends on mysql database.
mysqldump -uroot -p --all-databases --flush-privileges
--force
Ignore SQL errors that occur during export.
mysqldump -uroot -p --all-databases --force
--help
Display help information and exit.
mysqldump --help
--hex-blob
exports binary string fields in hexadecimal format. This option must be used if binary data is available. Affected field types are BINARY, VARBINARY, BLOB.
mysqldump -uroot -p --all-databases --hex-blob
--host, -h
host information to be exported
mysqldump -uroot -p --host=localhost --all-databases
--ignore-table
Do not export the specified table . When specifying to ignore multiple tables, it needs to be repeated multiple times, one table at a time. Each table must specify both the database and table name. For example: --ignore-table=database.table1 --ignore-table=database.table2 ...
mysqldump -uroot -p --host=localhost --all-databases --ignore-table=mysql.user
--include- master-host-port
adds 'MASTER_HOST=<host>, MASTER_PORT=<port>' to the 'CHANGE MASTER TO..' statement generated by --dump-slave
mysqldump -uroot -p --host=localhost --all-databases --include-master-host-port
--insert-ignore
Use the INSERT IGNORE statement when inserting rows.
mysqldump -uroot -p --host=localhost -- all-databases --insert-ignore
--lines-terminated-by
Each line of the output file is delimited with the given string. Used with the --tab option, cannot be used with the --databases and --all-databases options.
mysqldump -uroot -p --host=localhost test test --tab=”/tmp/mysql” --lines-terminated-by=”##”
--lock-all-tables, -x
submit request to lock all databases All tables to ensure data consistency. This is a global read lock and is automatically turned off with the --single-transaction and --lock-tables options.
mysqldump -uroot -p --host=localhost --all-databases --lock-all-tables
--lock-tables, -l
Lock all tables before starting the export. Lock the table with READ LOCAL to allow parallel inserts to MyISAM tables. For transaction-enabled tables such as InnoDB and BDB, --single-transaction is a better choice because it does not require locking the table at all.
Note that when exporting multiple databases, --lock-tables locks the tables separately for each database. Therefore, this option does not guarantee logical consistency across databases for the tables in the export file. The export status of different database tables can be completely different.
mysqldump -uroot -p --host=localhost --all-databases --lock-tables
--log-error
Append warning and error messages to the given file
mysqldump -uroot -p --host=localhost --all-databases - -log-error=/tmp/mysqldump_error_log.err
--max_allowed_packet
The maximum packet length sent and received by the server.
mysqldump -uroot -p --host=localhost --all-databases --max_allowed_packet=10240
--net_buffer_length
Buffer size for TCP/IP and socket connections.
mysqldump -uroot -p --host=localhost --all-databases --net_buffer_length=1024
--no-autocommit
Wrap tables with autocommit/commit statements.
mysqldump -uroot -p --host=localhost --all-databases --no-autocommit
--no-create-db, -n
Only export the data without adding a CREATE DATABASE statement.
mysqldump -uroot -p --host=localhost --all-databases --no-create-db
--no-create-info, -t
only exports data without adding a CREATE TABLE statement.
mysqldump -uroot -p --host=localhost --all-databases --no-create-info
--no-data, -d
does not export any data, only the database table structure.
mysqldump -uroot -p --host=localhost --all-databases --no-data
--no-set-names, -N is
equivalent to --skip-set-charset
mysqldump -uroot -p --host=localhost - -all-databases --no-set-names
--opt is
equivalent to --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock- tables, --set-charset, --disable-keys This option is enabled by default and can be disabled with --skip-opt.
mysqldump -uroot -p --host=localhost --all-databases --opt
--order-by-primary
If there is a primary key, or the first unique key, sort the records of each table. Works when exporting MyISAM tables to InnoDB tables, but makes the export take a long time.
mysqldump -uroot -p --host=localhost --all-databases --order-by-primary
--password, -p
connect database password
--pipe (available for windows system)
use named pipe to connect mysql
mysqldump -uroot -p - -host=localhost --all-databases --pipe
--port, -P
connection database port number
--protocol
The connection protocol used, including: tcp, socket, pipe, memory.
mysqldump -uroot -p --host=localhost --all-databases --protocol=tcp
--quick, -q
Do not buffer queries, export directly to standard output. On by default, use --skip-quick to disable this option.
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-quick
--quote-names,-Q
Use (`) to cause table and column names. On by default, use --skip-quote-names to disable this option.
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-quote-names
--replace
REPLACE INTO instead of INSERT INTO.
mysqldump -uroot -p --host=localhost --all-databases --replace
--result-file, -r
Output directly to the specified file. This option should be used on systems that use carriage-return-line-feed pair (\\r\\n) to wrap lines (eg: DOS, Windows). This option ensures that only one row is used.
mysqldump -uroot -p --host=localhost --all-databases --result-file=/tmp/mysqldump_result_file.txt
--routines, -R
exports stored procedures and custom functions.
mysqldump -uroot -p --host=localhost --all-databases --routines
--set-charset
adds 'SET NAMES default_character_set' to the output file. On by default, use the --skip-set-charset option to turn off.
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-set-charset
--single-transaction
This option submits a BEGIN SQL statement, BEGIN will not block any application and can guarantee the consistent state of the database when exporting. It only works with multi-version storage engines, only InnoDB. This option and the --lock-tables option are mutually exclusive, because LOCK TABLES makes any pending transaction implicitly committed. To export large tables, use the --quick option in combination.
mysqldump -uroot -p --host=localhost --all-databases --single-transaction
--dump-date
adds the export time to the output file. On by default, use the --skip-dump-date option to turn off.
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-dump-date
--skip-opt
Disable the --opt option.
mysqldump -uroot -p --host=localhost --all-databases --skip-opt
--socket,-S
Specify the location of the socket file connected to mysql, the default path /tmp/mysql.sock
mysqldump -uroot -p --host=localhost --all-databases --socket=/tmp/mysqld.sock --tab
,-T
for each Table creates a tab-separated text file at the given path. Note: Only for mysqldump and mysqld server running on the same machine.
mysqldump -uroot -p --host=localhost test test --tab="/home/mysql"
--tables
overrides the --databases (-B) parameter and specifies the name of the table to be exported.
mysqldump -uroot -p --host=localhost --databases test --tables test
--triggers
export triggers. This option is enabled by default, use --skip-triggers to disable it.
mysqldump -uroot -p --host=localhost --all-databases --triggers
--tz-utc
Set the time zone TIME_ZONE='+00:00' at the top of the export to ensure that TIMESTAMP data or data exported in different time zones are moved Correctness in other time zones.
mysqldump -uroot -p --host=localhost --all-databases --tz-utc
--user, -u
specifies the username to connect to.
--verbose, --v
output various platform information.
--version, -V
outputs mysqldump version information and exits
--where, -w
dumps only the records selected by the given WHERE condition. Note that if the condition contains spaces or characters specific to the command interpreter, be sure to quote the condition.
mysqldump -uroot -p --host=localhost --all-databases --where=” user='root'”
--xml, -X
export XML format.
mysqldump -uroot -p --host=localhost --all- databases --xml
--plugin_dir
Directory of client plugins for compatibility with different plugin versions.
mysqldump -uroot -p --host=localhost --all-databases --plugin_dir=”/usr/local/lib/plugin”
--default_auth
client plugin uses default permissions.
mysqldump -uroot -p --host=localhost --all-databases --default-auth=”/usr/local/lib/plugin/<PLUGIN>”

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326367042&siteId=291194637