Monday, December 21, 2009

How to take database backup in MySQL

Q. How to take database backup in MySQL

I will explain different options of taking database backup in MySQL server. Let support I have database 'TestDB' which I want to take backup of with different options.

# mysqldump -uroot -ppassword TestDB >TestDB.sql

If your database contains procedures and function then use -R flag and the modified command would be as follows;

# mysqldump -uroot -ppassword TestDB -R > TestDB.sql

What if you only want to take backup of table structures then commands will look as given below.


# mysqldump -uroot -ppassword -d TestDB > TestDB.sql

1 comment: