Linux Backup and Restore MySQL Databases Using mysqldump

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

Quick instructions:
backup: # mysqldump -u root -p[root_password] [database_name] > dumpdatabasefilename.sql

restore:# mysql -u root -p[root_password] [database_name] < dumpdatabasefilename.sql

Backup:
If you want to backup multiple databases at the same time, run show databases in mysql shell:
#mysql -u root -p[password]
mysql> show databases;


Multiple databases backup:
# mysqldump -u root -p[password] --databases database1 database2 > database_1_2.sql

One command to backup all databases in once:
#mysqldump -u root -ppassword --all-databases > all-database.sql

Backup a specific table:
# mysqldump -u root -ptmppassword sugarcrm accounts_contacts \
> /tmp/sugarcrm_accounts_contacts.sql

Restore
Make sure to create the database before you can perform the restore.
# mysql -u root -p[password]
mysql> create database somedatabase;
Query OK, 1 row affected (0.02 sec)
# mysql -u root -p[password] somedatabase < /tmp/somedatabase.sql
# mysql -u root -p[root_password] [database_name] < dumpfilename.sql

Backup a local database and restore to remote server using single command:
[local-server]# mysqldump -u root -p[password] sugarcrm | mysql \
-u root -p[password] --host=remote-server -C sugarcrm1

Read More