Back up database
# Mysqldump Database Name> Database Backup name
# Mysqldump-a-u username-P Password Database Name> Database Backup name
# Mysqldump-D-A -- add-drop-table-uroot-P> XXX. SQL
1. the exported structure does not export data
Mysqldump-D database name-uroot-P> XXX. SQL
2. Export data without exporting the 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 [Options] database [Tables]
Mysqldump supports the following options:
-- Add-locks
Add lock tables and unlock table before each table is exported. (To make it faster to insert data to MySQL ).
-- Add-drop-table
Add a drop table before each create statement.
-- Allow-keywords
Names of columns allowed to be created as 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, all information is compressed 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]
Tracking 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 Out the log files on the MySQL server before starting the export.
-F, -- force,
Even if we get an SQL error while exporting 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 start export.
-T, -- no-create-Info
Create table statement)
-D, -- no-Data
No row information is written to the table. If you only want to export the structure of a table, this is very useful!
-- OPT
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]
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
The TCP/IP Port used to connect to a host. (This is used to connect to a host other than localhost because it uses UNIX sockets .)
-Q, -- quick
Directly export the data to stdout without buffering the query; Use mysql_use_result () to do it.
-S/path/to/socket, -- socket =/path/to/socket
The socket file used when connecting to localhost (which is the default host.
-T, -- tab = path-to-some-directory
For each given table, create a table_name. SQL file that contains the SQL CREATE command and a table_name.txt file that 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
The username used by MySQL to connect 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
Lengthy mode. Print out more information about the program.
-V, -- version
Print the version information and exit.
-W, -- where = 'where-condition'
Only selected records are exported. Note that the quotation marks are mandatory!
"-- Where = user = 'jimf '"-wuserid> 1 ""-wuserid <1"
Import data:
Mysqldump exports complete SQL statements, so it is easy to import data into MYSQL client programs:
# MySQL database name <file name
# Source/tmp/xxx. SQL
Http://blogold.chinaunix.net/u/30002/showart_319262.html