Tuesday, December 24, 2013

Backup and restore MySQL database using mysqldump

Backup:
To backup a mysql database, you can use the following command:

 mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql

example:  mysqldump -u root -ppassword testdb > backup.sql


Restore:
To restore a mysql database, you can use the following command:

 mysql -u root -p[root_password] [database_name] < dumpfilename.sql

example:  mysql -u root -ppassword testdb < backup.sql