mysql export table structure, insert statements, and export Parameter Description

First, the relevant export statement

1, export the database (with drop table structure, the table data):

      mysqldump -uroot -p --databases database table name --tables Table 1 name 2> E: db1.sql

         --tables Table 2 is an optional field.

2, with the proviso export database table data (with the drop table structure, data table):

          mysqldump -uroot -p --databases --tables database table name = --where field name = 'field value'> E: a1.sql

3, only export the table structure (with a drop statement)

      mysqldump -uroot -p --opt -d database name> E: 123123.sql

     mysqldump -uroot -p --no-data --databases database name> E: db1.sql

4, only export the table structure (with no drop statement)

mysqldump -uroot -p123456 --skip-extended-insert --complete-insert -t watches database name (multiple)> E: /123.sql

-t: Cancel construction of the table statement.

--skip-extended-insert: one record per line.

--complete-insert: insert statements with a full field names.

--skip-add-drop-table: Cancellation drop table statement.

-h connect to a remote database -h 192.168.30.62

-P port number

Example: The data 192.168.26.128:3306/test database table in which the three export sql file to insert into a complete statement.

mysqldump -h 192.168.26.128 -P 3306 -uroot  -p  --skip-extended-insert --complete-insert -t  test CONTACT_CERTIFICATE CONTACT_MECH CUSTOMER_INFO  >E:/test.sql

Second, the parameters related to mysqldump description:

1, - all-databases export all databases.

mysqldump  -uroot -p --all-databases

2, - all-tablespaces export all table spaces

mysqldump  -uroot -p --all-databases --all-tablespaces

3, - no-tablespaces does not export any table space information.

mysqldump  -uroot -p --all-databases --no-tablespaces

4, - Add drop database statement before the add-drop-database is created for each database.

mysqldump  -uroot -p --all-databases --add-drop-database

5, - add-drop-table data add drop table statement before each data table creation.

    (Turned on by default, use --skip-add-drop-table option to cancel )
mysqldump --all-uroot--p-Databases (default statement added drop)
mysqldump --all-uroot--p-Databases the --skip-Add- drop-table (to cancel the drop statement)

6, - add-locks to increase LOCK TABLES before and after each table derived UNLOCK TABLE.

(Turned on by default, use --skip-add-locks cancel options)
mysqldump --all-uroot--p-Databases (added by default LOCK statement)
mysqldump --all-uroot--p-Databases the --skip-the Add-Locks ( cancel LOCK statement)

7, - allow-keywords are keyword allows you to create a column name. This is done by the table name prefix to each column name.

mysqldump  -uroot -p --all-databases --allow-keywords

8, - apply-slave-statements in the 'CHANGE MASTER' before adding 'STOP SLAVE', and finally adding the derived 'START SLAVE'.

mysqldump  -uroot -p --all-databases --apply-slave-statements

9, - character-sets-dir directory character set files

mysqldump  -uroot -p --all-databases  --character-sets-dir=/usr/local/mysql/share/mysql/charsets

10, - comments additional notes. The default is open, you can cancel with --skip-comments

mysqldump -uroot -p --all-databases (the default log comments)
mysqldump --all-uroot--p---skip-Databases Comments (uncommented)

11, - compatible export data will be compatible with other databases or an old version of MySQL.

Value can be ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_tables_options, no_field_options the like,
to use several values, they are separated by commas. It does not guarantee full compatibility, but as far as possible compatible.
mysqldump -uroot -p --all-databases --compatible = ansi

12, - compact derived output less (for debugging). Note remove head and tail like structures.

可以使用选项:--skip-add-drop-table  --skip-add-locks --skip-comments --skip-disable-keys
mysqldump  -uroot -p --all-databases --compact

13, - complete-insert, -c Use complete insert statements (column contains the name).

Doing so can improve the insertion efficiency, but may be affected max_allowed_packet parameters which led to the insertion fails.
mysqldump -uroot -p --all-databases --complete- insert

14, - compress, -C between the client and the server compression transmission enable all of the information

mysqldump  -uroot -p --all-databases --compress

15, - create-options, -a include all characteristics of MySQL option in the CREATE TABLE statement. (On by default)

mysqldump  -uroot -p --all-databases

16, - databases, -B export several databases. Parameter name behind all the parameters are seen as the database name.

mysqldump  -uroot -p --databases test mysql

17, - debug output debug information for debugging.

默认值为:d:t,/tmp/mysqldump.trace
mysqldump  -uroot -p --all-databases --debug
mysqldump  -uroot -p --all-databases --debug=” d:t,/tmp/debug.trace”

18, - debug-check to check memory and open files and exit instructions.

mysqldump  -uroot -p --all-databases --debug-check

19, - debug-info output debugging information and exit

mysqldump  -uroot -p --all-databases --debug-info

20, - default-character-set set a default character set, the default value utf8

mysqldump  -uroot -p --all-databases --default-character-set=utf8

21, - delayed-insert a time delay insert mode (INSERT DELAYED) export data

mysqldump  -uroot -p --all-databases --delayed-insert

22, - delete-master-logs deleted after the log backup master.

This parameter is automatically activated --master-data.

mysqldump  -uroot -p --all-databases --delete-master-logs

23、--disable-keys

For each table, with / * 40000 ALTER TABLE tbl_name DISABLE KEYS * /;! And / * 40000 ALTER TABLE tbl_name ENABLE KEYS * /;! Statement references INSERT statement. This will import more quickly out of the dump file because it is inserted in the indexes are created after all rows. This option is only for MyISAM tables turned on by default.
mysqldump -uroot -p --all-databases 

24, - dump-slave binlog This option will be master of the location and file name is appended to the file export data (show slave status).

When set to 1, it will be in CHANGE MASTER command output to the data file; set to 2, will add comments before change. This option will open --lock-all-tables, unless --single-transaction is specified. This option will automatically turn off --lock-tables option. The default value is 0.
Databases -uroot--p---all the mysqldump --dump-Slave. 1 =
the mysqldump --all -uroot--p-Slave---dump Databases = 2

25, - master-data this option binlog location and file name of the current server is added to the output file (show master status).

If it is 1, the output will CHANGE MASTER command; if the former is to add annotations 2, the output command CHANGE MASTER. This option will open --lock-all-tables option, unless --single-transaction also is specified (in this case, a global read lock is acquired for a short time at the beginning of the export; other content refer to the following --single -transaction option). This option automatically turns off --lock-tables option.
-uroot---host = localhost -p the mysqldump --all-Data-Databases = --master. 1;
the mysqldump --host = localhost -uroot---all -p-Data---master Databases = 2;

26, - events, -E Export Events.

mysqldump  -uroot -p --all-databases --events

27, - extended-insert, -e having a plurality of syntax INSERT VALUES column.

This allows the export file smaller, and speed during acceleration import. Is on by default, use --skip-extended-insert option to cancel.
-p --all-Databases-uroot-mysqldump
mysqldump --all-uroot--p-Databases - Skip-Extended-INSERT (Cancel option)

28, - fields-terminated-by ignored the exported file in a given field.

Used with --tab option can not be used --databases and --all-databases option
mysqldump -uroot -p test test --tab = " / home / mysql" --fields-terminated-by = "#"

29, - fields-enclosed-by each field in the output file with a given character wrapped.

Used with --tab option can not be used --databases and --all-databases option
mysqldump -uroot -p test test --tab = " / home / mysql" --fields-enclosed-by = "#"

30, - fields-optionally-enclosed-by output file with the fields in the parcel to the character set selectively.

Used with --tab option can not be used --databases and --all-databases option
mysqldump -uroot -p test test --tab = " / home / mysql" --fields-enclosed-by = "#" - -fields-optionally-enclosed-by = "#"

31, - fields-escaped-by the fields in the output file to ignore the given character.

Used with --tab option can not be used --databases and --all-databases option
mysqldump -uroot -p mysql user --tab = " / home / mysql" --fields-escaped-by = "#"

32, - refresh the log flush-logs Before the start exporting.

Note: If you export multiple databases once (using the option --databases or --all-databases), will refresh the logs one by one database. In addition to using --lock-all-tables or --master-data. In this case, the log will be refreshed once, so the corresponding table is locked at the same time. Therefore, if you plan to export both logs and refresh should use --lock-all-tables or --master-data and --flush-logs.
mysqldump -uroot -p --all-databases --flush- logs

33, - flush-privileges derived mysql database after issuing a FLUSH PRIVILEGES statement.

In order to properly recover, this option should be used to export the mysql database mysql database and dependent data at any time.
mysqldump -uroot -p --all-databases --flush- privileges

34, - force ignore SQL errors that occur during the export process.

mysqldump  -uroot -p --all-databases --force

35, - help display help information and exit.

mysqldump  --help

36, - hex-blob hexadecimal format export binary string field.

If there is binary data must use this option. The field types are affected BINARY, VARBINARY, BLOB.
mysqldump -uroot -p --all-databases --hex- blob

37, - host, -h host information needed to export

mysqldump  -uroot -p --host=localhost --all-databases

38, - ignore-table does not specify the export table. When specify more than one table to ignore, need to be repeated several times, each time a table.

Each table must specify both the database and table names. For example: - the ignore---ignore-database.table1 = Table = Table ...... database.table2
the mysqldump --all -uroot--p---host = localhost Databases = Table---ignore the mysql.user

39、--include-master-host-port   

Produced in --dump-slave 'CHANGE MASTER TO ..' statement increase 'MASTER_HOST = <host>, MASTER_PORT = <port>'  

mysqldump  -uroot -p --host=localhost --all-databases --include-master-host-port

40, - insert-ignore rows inserted using INSERT IGNORE statement.

mysqldump  -uroot -p --host=localhost --all-databases --insert-ignore

41, - each row lines-terminated-by the output file with the given string dividing.

Used with --tab option can not be used --databases and --all-databases option.
mysqldump -uroot -p --host = localhost test test --tab = "/ tmp / mysql" --lines-terminated-by = "##"

42, - lock-all-tables, -x submit a request to lock all the tables in all databases to ensure data consistency.

This is a global read lock, and automatically turn off --single-transaction and --lock-tables option.
mysqldump -uroot -p --host = localhost --all- databases --lock-all-tables

43, - lock-tables, -l before start the export lock all the tables.

Lock table for READ LOCAL to allow concurrent insert MyISAM table. For transactional tables such as InnoDB and BDB, - single-transaction is a better choice, because it does not need to lock the table.
Note that when exporting multiple databases, - lock-tables separately for each database table is locked. Therefore, this option does not guarantee the exported file table between the logical consistency of the database. Exporting Tables in different databases can be completely different.
mysqldump -uroot -p --host = localhost --all- databases --lock-tables

44, - log-error Additional warning and error messages to the given file

mysqldump  -uroot -p --host=localhost --all-databases  --log-error=/tmp/mysqldump_error_log.err

45, - max_allowed_packet server to send and receive a maximum length packet.

mysqldump  -uroot -p --host=localhost --all-databases --max_allowed_packet=10240

46, - the buffer size net_buffer_length TCP / IP and socket connection.

mysqldump  -uroot -p --host=localhost --all-databases --net_buffer_length=1024

47, - no-autocommit use autocommit / commit statement wrapping table.

mysqldump  -uroot -p --host=localhost --all-databases --no-autocommit

48, - no-create-db, -n export data only, without adding CREATE DATABASE statement.

mysqldump  -uroot -p --host=localhost --all-databases --no-create-db

49, - no-create-info  , -t    export data only, without adding CREATE TABLE statement.

mysqldump  -uroot -p --host=localhost --all-databases --no-create-info

50, - no-data, -d does not export any data, only export the database table structure.

mysqldump  -uroot -p --host=localhost --all-databases --no-data

51, - no-set-names, -N equivalent --skip-set-charset

mysqldump  -uroot -p --host=localhost --all-databases --no-set-names

52、--opt   

Equivalent --add-drop-table, --add- locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, --disable-keys that option is enabled by default, can be disabled with the opt---skip.
mysqldump --host = localhost -p-uroot---all-Databases --opt

53, - order-by-primary if the primary key or a unique key exists first, sorting the records of each table.

When you export a table to InnoDB MyISAM table is valid, but that the derived work takes a long time. 
mysqldump -uroot -p --host = localhost --all- databases --order-by-primary

54, - password, -p password database connection

55, - pipe (windows system may be used) using a named pipe connection mysql

mysqldump  -uroot -p --host=localhost --all-databases --pipe

56, - ​​port, -P port number connected to the database

57, - the connection protocol of the protocol used, comprising: tcp, socket, pipe, memory.

mysqldump  -uroot -p --host=localhost --all-databases --protocol=tcp

58, - quick, -q not buffer query, direct export to stdout.

Is on by default, use --skip-quick cancel the option.
-uroot---host = localhost -p the mysqldump --all-Databases 
the mysqldump --host = localhost -uroot---all -p-Quick-Databases --skip

59, - quote-names, -Q use ( `) to cause table and column names.

Is on by default, use --skip-quote-names cancel the option.
-uroot---host = localhost -p the mysqldump --all-Databases
the mysqldump --all -uroot--p---host = localhost Databases --skip-quote-names

60, - replace using REPLACE INTO substituted INSERT INTO.

mysqldump  -uroot -p --host=localhost --all-databases --replace

61, - result-file, -r directly to the specified output file.

This option should be used on systems that use line breaks to (\\ r \\ n) line feed (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

62, - routines, -R export stored procedures and custom functions.

mysqldump  -uroot -p --host=localhost --all-databases --routines

63, - set-charset Add 'SET NAMES default_character_set' to the output file.

It is on by default, use --skip-set-charset off option.
-uroot---host = localhost -p the mysqldump --all-Databases 
the mysqldump --all -uroot--p---host = localhost Databases --skip-SET-charset

64、--single-transaction

The option to submit a BEGIN SQL statement before exporting the data, BEGIN does not block any applications and can ensure the consistency of the database status when exported. It applies only to multi-storage engine version, only InnoDB. This option and --lock-tables option are mutually exclusive, because LOCK TABLES causes any pending transaction implicitly committed. To export a large table, use --quick option should be combined.
mysqldump -uroot -p --host = localhost --all- databases --single-transaction

65, - dump-date export time is added to the output file.

It is on by default, use --skip-dump-date shutdown option.
-uroot---host = localhost -p the mysqldump --all-Databases
the mysqldump --all -uroot--p---host = localhost Databases the dump-DATE---skip

66, - skip-opt disabled -opt option.

mysqldump  -uroot -p --host=localhost --all-databases --skip-opt

67, - socket, -S file location specified socket connection mysql, the default path /tmp/mysql.sock

mysqldump  -uroot -p --host=localhost --all-databases --socket=/tmp/mysqld.sock

68, - tab, -T each table to create a text file tab split a given path.

Note: Only for mysqldump mysqld and server run on the same machine. Note the use of --tab --databases not specify parameters
mysqldump -uroot -p --host = localhost test test --tab = "/ home / mysql"

69, - tables covering --databases (-B) parameter specifies the name of the table to be exported, the latter will be used in the version table substitution tables.

mysqldump  -uroot -p --host=localhost --databases test --tables test

70, - triggers export trigger.

This option is enabled by default, disable it with --skip-triggers.
mysqldump -uroot -p --host = localhost --all- databases --triggers

71, - tz-utc when exporting top zone disposed TIME_ZONE = '+ 00:00',

To ensure correct when the time zone is moved in the other time zones TIMESTAMP data or derived data.
mysqldump -uroot -p --host = localhost --all- databases --tz-utc

72, - user, -u user name designated connection.

73, - verbose, --v output multiple platform information.

74, - version, -V output version information and exit mysqldump

75, - where, -w dump to record only given WHERE condition of choice.

Please note that if your command interpreter special conditions contain spaces or characters, be sure to reference conditions together.
mysqldump -uroot -p --host = localhost --all- databases --where = "user = 'root'"

76, - xml, -X exported in XML format.

mysqldump  -uroot -p --host=localhost --all-databases --xml

77, - plugin_dir client plug-in directory for compatibility with different plug-in versions.

mysqldump  -uroot -p --host=localhost --all-databases --plugin_dir=”/usr/local/lib/plugin”

78, - default_auth client plug-in default permissions.

mysqldump  -uroot -p --host=localhost --all-databases --default-auth=”/usr/local/lib/plugin/<PLUGIN>”

 

 

Published 13 original articles · won praise 1 · views 7823

Guess you like

Origin blog.csdn.net/weixin_40482816/article/details/87074689