Utility to dump a database or a collection of database for backup or for transferring the data to another SQL server. The dump will contain SQL statements to create the table and/or populate the table.
shell> mysqldump [OPTIONS] database [tables]
If you don't give any tables, the whole database will be dumped.
You can get a list of the options your version of mysqldump supports
by executing mysqldump --help.
Note that if you run mysqldump without --quick or
--opt, mysqldump will load the whole result set into
memory before dumping the result. This will probably be a problem if
you are dumping a big database.
mysqldump supports the following options:@:
--add-locks
LOCK TABLES before and UNLOCK TABLE after each table dump.
(To get faster inserts into MySQL).
--add-drop-table
drop table before each create statement.
--allow-keywords
-c, --complete-insert
-C, --compress
--delayed
INSERT DELAYED command.
-e, --extended-insert
INSERT syntax. (Gives more compact and
faster inserts statements)
-#, --debug[=option_string]
--help
--fields-terminated-by=...
--fields-enclosed-by=...
--fields-optionally-enclosed-by=...
--fields-escaped-by=...
--fields-terminated-by=...
-T option and have the same
meaning as the corresponding clauses for LOAD DATA INFILE.
LOAD DATA.
-F, --flush-logs
-f, --force,
-h, --host=..
localhost.
-l, --lock-tables.
-t, --no-create-info
CREATE TABLE statment)
-d, --no-data
--opt
--quick --add-drop-table --add-locks --extended-insert
--use-locks. Should give you the fastest possible dump for reading
into a MySQL server.
-pyour_pass, --password[=your_pass]
mysqldump solicits the password from the terminal.
-P port_num, --port=port_num
localhost, for which Unix sockets are
used.)
-q, --quick
mysql_use_result()
to do this.
-S /path/to/socket, --socket=/path/to/socket
localhost (which is the
default host).
-T, --tab=path-to-some-directory
table_name.sql file, that conntains the SQL CREATE commands,
and a table_name.txt file, that contains the data, for each give table.
NOTE:@: This only works if mysqldump is run on the same
machine as the mysqld daemon. The format of the .txt file
is made according to the --fields-xxx and --lines--xxx options.
-u user_name, --user=user_name
-O var=option, --set-variable var=option
-v, --verbose
-V, --version
-w, --where='where-condition'
"--where=user='jimf'" "-wuserid>1" "-wuserid<1"
The most normal use of mysqldump is probably for making a backup of
whole database:@:
mysqldump --opt database > backup-file.sql
But it's also very useful to populate another MySQL server with information from a databas:@:
mysqldump --opt database | mysql --host=remote-host -C database