Wednesday, October 28, 2009

MySQL command line for backup and restore database

To backup:
$ mysqldump -u user -p[passwd] [dbname] > [sqlfile]
To restore:
$ mysql -u user -p[passwd] [dbname] < [sqlfile]
Ex: to export (dump) and import a backup of database "data1" with user "user1" and password "passwd1" on "localhost" to "backup.sql" use below command:
$ mysqldump -u user1 -ppass1 data1 > backup.sql
$ mysql -u user1 -ppass1 data1 < backup.sql

Read more here:

No comments:

Post a Comment