mysql dump and restore.

i’ve seen a tremendous amount of different syntaxes for the most simplest database dumps and restore. why worry about the details? this is how you perform a database backup:
$ mysqldump -u username -p databasename > filename.sql
type your password at the prompt, wait a few seconds, and you now have a perfectly good .sql file that represents your database schema and all the data within.
to restore your database, use the following:
$ mysql -u username -p databasename < filename.sql
enter your password once again at the prompt. this input assumes that you have a file named filename.sql in the directory in which you are performing the backup. you can reference the /path/to/filename.sql as well.
that’s all there is to it. if you need to change any data before the restore, simply edit the filename.sql with your favorite editor (but for your own sake, make sure it’s not that large!)

Leave a Reply

Post Navigation