MySQL DATA export and import tool: mysqldump (Database Backup command)

Source: Internet
Author: User
Tags directory create sql error

MySQL DATA export and import tool: mysqldump (Database Backup command) backup database # mysqldump Database Name> Database Backup name # mysqldump-A-u username-p Password Database [size = large] Name> Database Backup name # mysqldump-d-A -- add- drop-table-uroot-p> xxx. SQL [size = large] 1. export structure does not export data mysqldump-d database name-uroot-p> xxx. SQL 2. export data without exporting structure mysqldump-t database name-uroot-p> xxx. SQL 3. export data and table structure mysqldump database name-uroot-p> xxx. SQL 4. export the structure of a specific table: mysqldump-uroot-p-B database name -- table Name> xxx. SQL # mysqldump [OPT IONS] database [tables] mysqldump supports the following options: -- add-locks adds lock tables before each TABLE is exported and then UNLOCK the TABLE. (To make it faster to insert data to MySQL ). -- Add-drop-table: add a drop table before each create statement. -- Allow-keywords allows the creation of column names that are keywords. This is done by the table name prefix on each column name. -C, -- complete-insert use the complete insert Statement (with the column name ). -C, -- compress: if both the client and server support compression, compress all information between the two. -- Delayed use the insert delayed command to INSERT rows. -E, -- extended-insert use the new multiline INSERT syntax. (A more compact and faster insert statement is provided)-#, -- debug [= option_string] use of the tracing program (for debugging ). -- Help: displays a help message and exits. -- Fields-terminated-by =... -- fields-enclosed-by =... -- fields-optionally-enclosed-by =... -- fields-escaped-by =... -- fields-terminated-by =... these options are used with-T options and have the same meaning as the load data infile clause. Load data infile syntax. -F, -- flush-logs: wash the log files on the MySQL server before export. -F, -- force, even if we get an SQL error during the export of a table, continue. -H, -- host = .. export data from the MySQL server on the named host. The default host is localhost. -L, -- lock-tables. lock all tables for export start. -T, -- no-create-info does not write the TABLE creation Information (create table statement)-d, -- no-data does not write any row information of the TABLE. If you only want to export the structure of a table, this is very useful! -- Opt is the same as -- quick -- add-drop-table -- add-locks -- extended-insert -- lock-tables. You should be given the fastest export possible for reading a MySQL server. -Pyour_pass, -- password [= your_pass] indicates the password used to connect to the server. If you do not specify "= your_pass", mysqldump requires a password from the terminal. -P port_num, -- port = port_num indicates the TCP/IP port number used to connect to a host. (This is used to connect to a host other than localhost because it uses Unix sockets .) -Q, -- quick does not buffer queries and is exported directly to stdout. Use mysql_use_result () to do it. -S/path/to/socket, -- socket =/path/to/socket the socket file used when connecting to localhost (it is the default host. -T, -- tab = path-to-some-directory CREATE a table_name. SQL file for each given table, which contains the SQL CREATE command and a table_name.txt file, which contains data. Note: This only works when mysqldump runs on the same machine where the mysqld daemon is running .. The format of the txt file is determined by the options -- fields-xxx and -- lines -- xxx. -U user_name, -- user = user_name: username used by MySQL when connecting to the server. The default value is your Unix login name. -O var = option, -- set-variable var = option to set the value of a variable. Possible variables are listed below. -V, -- verbose mode. Print out more information about the program. -V, -- version: print the version information and exit. -W, -- where = 'where-condition 'only exports the selected records. Note that the quotation marks are mandatory! "-- Where = user = 'jimf '"-wuserid> 1 ""-wuserid <1 "import data: mysqldump exports the complete SQL statement [size = large], so it is easy to import data using the mysql client program: # mysql database name <file name # source/tmp/xxx. SQL [/size] [/size] [/size]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.