How to Backup MySQL Database using mysqldump utility?

To take a backup of MySQL database or databases, the database must exist in the database server and you should have access to it.

The format of the command would be. 

# mysqldump -u [username] –p[password] [database_name] > [dump_file.sql]

How to Backup Remote MySQL Database

# mysqldump –h ipaddress -u [username] –p[password] [database_name] > [dump_file.sql]

How to Backup a Single MySQL Database?

# mysqldump -u root -proot123 MYDB1 > MYDB1.sql

How to Backup Multiple MySQL Databases?

# mysqldump -u root -proot123 --databases MYDB1 MYDB2 MYDB3 > MYDB1_MYDB2_MYDB3.sql

How to Backup All MySQL Databases?

# mysqldump -u root -proot123 --all-databases > alldb.sql

How to Backup MySQL Database Structure Only?

# mysqldump -u root -proot123 --no-data MYDB1 > MYDB1structure.sql

How to Backup MySQL Database Data Only?

# mysqldump -u root -proot123 --no-create-db --no-create-info MYDB1 > MYDB1data.sql

How to Backup Single Table of Database?

# mysqldump -u root -proot123 MYDB1 TABLE1 > TABLE1_MYDB1.sql

How to Backup Multiple Tables of Database?

# mysqldump -u root -proot123 MYDB1 TABLE1 TABLE2 > TABLE1_TABLE2_MYDB1.sql

Note:
To restore a MYSQL Database, you can refer my blog

No comments:

Post a Comment