当前位置:网站首页>Parameters of mysqldump
Parameters of mysqldump
2022-07-23 17:48:00 【Ideal coder】
from :http://www.cnblogs.com/qq78292959/p/3637135.html
Mysqldump Parameters ( The parameter comes from mysql5.5.19 Source code )
Parameters
Parameter description
--all-databases , -A
Export all databases .
mysqldump -uroot -p --all-databases
--all-tablespaces , -Y
Export all tablespaces .
mysqldump -uroot -p --all-databases --all-tablespaces
--no-tablespaces , -y
Do not export any tablespace information .
mysqldump -uroot -p --all-databases --no-tablespaces
--add-drop-database
Add... Before each database is created drop Database statement .
mysqldump -uroot -p --all-databases --add-drop-database
--add-drop-table
Add... Before each data table is created drop Data table statements .( The default is on , Use --skip-add-drop-table Cancel options )
mysqldump -uroot -p --all-databases ( Default add drop sentence )
mysqldump -uroot -p --all-databases –skip-add-drop-table ( Cancel drop sentence )
--add-locks
Add... Before each table export LOCK TABLES And then UNLOCK TABLE.( The default is on , Use --skip-add-locks Cancel options )
mysqldump -uroot -p --all-databases ( Default add LOCK sentence )
mysqldump -uroot -p --all-databases –skip-add-locks ( Cancel LOCK sentence )
--allow-keywords
Allow to create column names that are keywords . This is done by prefixing the table name with each column name .
mysqldump -uroot -p --all-databases --allow-keywords
--apply-slave-statements
stay 'CHANGE MASTER' Add before 'STOP SLAVE', And add... At the end of the export 'START SLAVE'.
mysqldump -uroot -p --all-databases --apply-slave-statements
--character-sets-dir
Directory of character set files
mysqldump -uroot -p --all-databases --character-sets-dir=/usr/local/mysql/share/mysql/charsets
--comments
Additional notes . It is on by default , It can be used --skip-comments Cancel
mysqldump -uroot -p --all-databases ( Default record comment )
mysqldump -uroot -p --all-databases --skip-comments ( uncomment )
--compatible
The exported data will be compared with other databases or old versions of MySQL Compatible with . The value can be ansi、mysql323、mysql40、postgresql、oracle、mssql、db2、maxdb、no_key_options、no_tables_options、no_field_options etc. ,
Use a few values , Separate them with commas . It's not guaranteed to be fully compatible , But try to be compatible .
mysqldump -uroot -p --all-databases --compatible=ansi
--compact
Export less output information ( For debugging ). Get rid of the comments and the head and tail structures . 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 complete insert sentence ( Include column names ). This can improve insertion efficiency , But there may be max_allowed_packet The parameter causes the insert to fail .
mysqldump -uroot -p --all-databases --complete-insert
--compress, -C
Enable compression to pass all information between client and server
mysqldump -uroot -p --all-databases --compress
--create-options, -a
stay CREATE TABLE The statement includes all MySQL Feature options .( The default is on )
mysqldump -uroot -p --all-databases
--databases, -B
Export several databases . All name parameters after 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:o,/tmp/mysqldump.trace
mysqldump -uroot -p --all-databases --debug
mysqldump -uroot -p --all-databases --debug=” d:t:o,/tmp/debug.trace”
--debug-check
Check memory and open file instructions and exit .
mysqldump -uroot -p --all-databases --debug-check
--debug-info
Output debugging information and exit
mysqldump -uroot -p --all-databases --debug-info
--default-character-set
Set default character set , The default value is utf8
mysqldump -uroot -p --all-databases --default-character-set=latin1
--delayed-insert
Delay insertion mode is adopted (INSERT DELAYED) Derived data
mysqldump -uroot -p --all-databases --delayed-insert
--delete-master-logs
master Delete log after 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 */; Statement reference INSERT sentence . This allows for faster import of dump The document came out , Because it creates the index after inserting all the rows . This option is only for MyISAM surface , The default is on .
mysqldump -uroot -p --all-databases
--dump-slave
This option will result in the main binlog The location and filename are appended to the exported data file . Set to 1 when , Will take CHANGE MASTER Command output to data file ; Set to 2 when , Add a description before the command . This option will turn on --lock-all-tables, Unless --single-transaction To be designated . This option turns off automatically --lock-tables Options . The default value is 0.
mysqldump -uroot -p --all-databases --dump-slave=1
mysqldump -uroot -p --all-databases --dump-slave=2
--events, -E
Export Events .
mysqldump -uroot -p --all-databases --events
--extended-insert, -e
Use with multiple VALUES Column INSERT grammar . This makes the export file smaller , And speed up the import . The default is on , Use --skip-extended-insert Cancel options .
mysqldump -uroot -p --all-databases
mysqldump -uroot -p --all-databases--skip-extended-insert ( Cancel options )
--fields-terminated-by
Ignore given field in export file . And --tab Use options together , Cannot be used for --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 in the given characters . And --tab Use options together , Cannot be used for --databases and --all-databases Options
mysqldump -uroot -p test test --tab=”/home/mysql” --fields-enclosed-by=”#”
--fields-optionally-enclosed-by
Each field in the output file is optionally wrapped with a given character . And --tab Use options together , Cannot be used for --databases and --all-databases Options
mysqldump -uroot -p test test --tab=”/home/mysql” --fields-enclosed-by=”#” --fields-optionally-enclosed-by =”#”
--fields-escaped-by
The fields in the output file ignore the given characters . And --tab Use options together , Cannot be used for --databases and --all-databases Options
mysqldump -uroot -p mysql user --tab=”/home/mysql” --fields-escaped-by=”#”
--flush-logs
Refresh log before starting export .
Please note that : If you export more than one database at a time ( Use options --databases perhaps --all-databases), The logs will be refreshed database by database . In addition to using --lock-all-tables perhaps --master-data Outside . under these circumstances , The log will be refreshed once , Accordingly, all tables are locked at the same time . therefore , If you plan to export and refresh logs at the same time, you should use --lock-all-tables perhaps --master-data and --flush-logs.
mysqldump -uroot -p --all-databases --flush-logs
--flush-privileges
Exporting mysql After database , Send out a FLUSH PRIVILEGES sentence . In order to recover correctly , This option should be used to export mysql Databases and dependencies mysql Any time the database data .
mysqldump -uroot -p --all-databases --flush-privileges
--force
Ignore the occurrence of SQL error .
mysqldump -uroot -p --all-databases --force
--help
Display help message and exit .
mysqldump --help
--hex-blob
Exporting binary string fields in hexadecimal format . You have to use this option if you have binary data . The types of fields affected 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 . Specifies that when multiple tables are ignored , It needs to be repeated many times , One watch at a time . Each table must specify both the database and the 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
stay --dump-slave Produced 'CHANGE MASTER TO..' Add in statement 'MASTER_HOST=<host>,MASTER_PORT=<port>'
mysqldump -uroot -p --host=localhost --all-databases --include-master-host-port
--insert-ignore
Use... When inserting rows INSERT IGNORE sentence .
mysqldump -uroot -p --host=localhost --all-databases --insert-ignore
--lines-terminated-by
Each line of the output file is divided by a given string . And --tab Use options together , Cannot be used for --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 tables in all databases , To ensure data consistency . This is a global read lock , And automatically turn off --single-transaction and --lock-tables Options .
mysqldump -uroot -p --host=localhost --all-databases --lock-all-tables
--lock-tables, -l
Before you start exporting , Lock all tables . use READ LOCAL Lock the table to allow MyISAM Table inserts in parallel . For tables that support transactions, for example InnoDB and BDB,--single-transaction It's a better choice , Because it doesn't need to lock the table at all .
Note that when exporting multiple databases ,--lock-tables Lock tables for each database separately . therefore , This option does not guarantee the logical consistency of the tables in the export file between databases . The export status of different database tables can be completely different .
mysqldump -uroot -p --host=localhost --all-databases --lock-tables
--log-error
Attach warning and error messages to the given file
mysqldump -uroot -p --host=localhost --all-databases --log-error=/tmp/mysqldump_error_log.err
--master-data
This option will binlog The location and filename of are appended to the output file . If 1, Will be output CHANGE MASTER command ; If 2, Output CHANGE MASTER Add comment information before command . This option will turn on --lock-all-tables Options , Unless --single-transaction It's also assigned ( under these circumstances , Global read locks get a very short time at the beginning of export ; For other information, please refer to --single-transaction Options ). This option turns off automatically --lock-tables Options .
mysqldump -uroot -p --host=localhost --all-databases --master-data=1;
mysqldump -uroot -p --host=localhost --all-databases --master-data=2;
--max_allowed_packet
Maximum packet length sent and received by the server .
mysqldump -uroot -p --host=localhost --all-databases --max_allowed_packet=10240
--net_buffer_length
TCP/IP and socket The cache size of the connection .
mysqldump -uroot -p --host=localhost --all-databases --net_buffer_length=1024
--no-autocommit
Use autocommit/commit Statement package table .
mysqldump -uroot -p --host=localhost --all-databases --no-autocommit
--no-create-db, -n
Export data only , Without adding CREATE DATABASE sentence .
mysqldump -uroot -p --host=localhost --all-databases --no-create-db
--no-create-info, -t
Export data only , Without adding CREATE TABLE sentence .
mysqldump -uroot -p --host=localhost --all-databases --no-create-info
--no-data, -d
Don't export any data , Only export database table structure .
mysqldump -uroot -p --host=localhost --all-databases --no-data
--no-set-names, -N
Equate to --skip-set-charset
mysqldump -uroot -p --host=localhost --all-databases --no-set-names
--opt
Equate to --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, --disable-keys This option is on by default , It can be used --skip-opt Ban .
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 . Exporting MyISAM Table to InnoDB The watch is valid , But it will take a long time to export .
mysqldump -uroot -p --host=localhost --all-databases --order-by-primary
--password, -p
Connection database password
--pipe(windows System available )
Use named pipe connections mysql
mysqldump -uroot -p --host=localhost --all-databases --pipe
--port, -P
Connection database port number
--protocol
Connection protocol used , Include :tcp, socket, pipe, memory.
mysqldump -uroot -p --host=localhost --all-databases --protocol=tcp
--quick, -q
Do not buffer queries , Export directly to standard output . The default is on , Use --skip-quick Cancel this option .
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-quick
--quote-names,-Q
Use (`) Cause table and column names . The default is on , Use --skip-quote-names Cancel this option .
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-quote-names
--replace
Use REPLACE INTO replace INSERT INTO.
mysqldump -uroot -p --host=localhost --all-databases --replace
--result-file, -r
Output directly to the specified file . This option should be used for use with carriage return linefeed pairs (\\r\\n) On a line feed system ( for example :DOS,Windows). This option ensures that only one line is used .
mysqldump -uroot -p --host=localhost --all-databases --result-file=/tmp/mysqldump_result_file.txt
--routines, -R
Export stored procedures and custom functions .
mysqldump -uroot -p --host=localhost --all-databases --routines
--set-charset
add to 'SET NAMES default_character_set' To the output file . The default is on , Use --skip-set-charset Turn off options .
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-set-charset
--single-transaction
This option submits a... Before exporting the data BEGIN SQL sentence ,BEGIN It will not block any application and can guarantee the consistency state of database when exporting . It only works with multi version storage engines , only InnoDB. This option and --lock-tables Options are mutually exclusive , because LOCK TABLES Any pending transactions will be implicitly committed . If you want to export a large watch , Should be used in combination with --quick Options .
mysqldump -uroot -p --host=localhost --all-databases --single-transaction
--dump-date
Add the export time to the output file . The default is on , Use --skip-dump-date Turn off options .
mysqldump -uroot -p --host=localhost --all-databases
mysqldump -uroot -p --host=localhost --all-databases --skip-dump-date
--skip-opt
Ban –opt Options .
mysqldump -uroot -p --host=localhost --all-databases --skip-opt
--socket,-S
Specify the connection mysql Of socket file location , The default path /tmp/mysql.sock
mysqldump -uroot -p --host=localhost --all-databases --socket=/tmp/mysqld.sock
--tab,-T
Create... For each table at a given path tab Split text file . Be careful : Only for mysqldump and mysqld The server runs on the same machine .
mysqldump -uroot -p --host=localhost test test --tab="/home/mysql"
--tables
Cover --databases (-B) Parameters , Specify the name of the table to export .
mysqldump -uroot -p --host=localhost --databases test --tables test
--triggers
Export trigger . This option is enabled by default , use --skip-triggers Disable it .
mysqldump -uroot -p --host=localhost --all-databases --triggers
--tz-utc
Set the time zone at the top of the export TIME_ZONE='+00:00' , In order to ensure the export of TIMESTAMP The correctness of data or data when it is moved to another time zone .
mysqldump -uroot -p --host=localhost --all-databases --tz-utc
--user, -u
Specify the user name of the connection .
--verbose, --v
Output multiple platform information .
--version, -V
Output mysqldump Version information and exit
--where, -w
Dump only the given WHERE Record of condition selection . Note that if the condition contains a command interpreter specific space or character , Be sure to refer to the conditions .
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 the client plug-in , For compatibility with different plug-in versions .
mysqldump -uroot -p --host=localhost --all-databases --plugin_dir=”/usr/local/lib/plugin”
--default_auth
The client plug-in is authorized by default .
mysqldump -uroot -p --host=localhost --all-databases --default-auth=”/usr/local/lib/plugin/<PLUGIN>”
边栏推荐
- "Now, the number of codes has expanded to astronomical level"
- MySQL7种JOIN(图)
- Kubernetes kubelet hard core knowledge architecture
- Record the range of data that MySQL update will lock
- Food safety | ham sausage lunch meat, is it really so unbearable?
- Solution to connection rejected error in idea download sources
- @Will multiple bean instances be created by multiple method calls of bean annotations
- Typescript empty array
- Kubernetes focuses on kubelet's responsibilities
- 卷积核越大性能越强?一文解读RepLKNet模型
猜你喜欢

Redis distributed lock, it's really impossible without it

网络基础设施可视化

SAP HANA数据库备份失败解决办法

sns_ sensor_ instance_ api

isEmpty 和 isBlank 的用法区别,至少一半的人答不上来...

MySQL7种JOIN(图)

Interviewer: what is the possible reason for the slow query of MySQL database besides the index problem?

几何参数化重构

Why do you get confused when you ask JVM???

Données chronologiques dans l'Internet industriel des objets
随机推荐
JDBC program example using Preparedstatement
为啥一问 JVM 就 懵B ???
Food safety | drinking fresh milk may infect tuberculosis? Take you to know what is milk sterilization
分页类
WARNING: Your password has expired.Password change required but no TTY available.
数智化时代文旅遇新机?中国移动咪咕造 “元宇宙第一岛”
Interviewer: how to use redis to realize distributed locks?
Redis分布式锁,没它真不行
Transfer business append log (transaction propagation behavior)
leetcode刷题:动态规划05(不同路径 II)
作为一名后台开发人员,你必须知道的两种过滤器
LeetCode_ 455_ Distribute cookies
WSUS can patch MySQL Middleware_ Join the WSUS patch server and download the patch
训练和测试的loss不下降,并且精度超低
ride the wind and waves! Digital transformation in the era of financial technology
Food safety | attention to smoking food, do you know this knowledge
SAP HANA数据库备份失败解决办法
Visualization of network infrastructure
MySQL主从同步延迟解决方案
Summary of stock historical data download interface (dynamic update)