Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to backup an MySQL database so that if something wrong occurs, it will be easy to recreate the tables with the same data?

share|improve this question

migrated from Apr 1 '10 at 0:53

This question came from our site for professional and enthusiast programmers.

Use mysqldump. But in its current form should go to – ChristopheD Mar 31 '10 at 22:47

Yes, there are lots of ways. There is a page in the documentation which summarizes many of the available methods.

For example, you could take a look at:

mysqldump db_name > dump_file
share|improve this answer

I have to agree with the

mysqldump db_name > dump_file

option. Just be warned, if you automate it, you will need to add the user name and password to the script for it run properly.

share|improve this answer
You can avoid passing the username and password on the command line by setting $HOME to a directory containing an appropriately-arranged .my.cnf or --defaults-extra-file if it's available. – Gerald Combs Oct 27 '11 at 22:48

mysqldump for quick and easy dumps of the database. But if you manage a few database servers and have a regular backup schedule you might try mysql-zrm which is a more sophisticated flexible approach.

It's a pain in the arse to setup but once you do you can easily search for and find individual backups based on date and other criteria. you can restore entire databases or just individual tables. you'll thank yourself if you take the time to do this and you have more than a simple need for an occasional backup to perform.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.