Jump to Navigation

060 - mysqldump

This utility exports MySQL data and table structures. Typically, you use it to make backups of database or
to copy database from one server to another. You can run it on an active server.
For consistency of data between tables, the table should be locked (--lock-table option) or mysqld
daemon should be shutdown.
There are three syntaxes for this utility. The first method shown makes a backup of all databases for
the server. The second method backs up specific database, named in a space-separated list, including
all tables in each database. The third method backs up specific tables of a specific database.

mysqldump [options] --all-databases
mysqldump [options] --database database [database ...]
mysqldump [options] database [table]

Example:

All Backups:
mysqldump --host=demo.myserver.com --user=user1 --password \
--lock-tables --all-database > /tmp/all_bk.sql
Specific backup:
mysqldump -u user1 -p --lock-tables demodb > /tmp/demodb_bk.sql
table backup:
mysqldump -u user1 -pPassword1 demodb table01 > /tmp/table01_bk.sql
Databse Copy:
mysqldump --compress -h localhost -u user1 -pPassword1 sample_drupal5 | mysql -h demo.myserver.net -u user1 -pPassword1 sample_drupal5

 

MySQL:


Main menu 2

Story | by Dr. Radut