Dumping databases for keeping in version control
Whenever you make a database change, dump it with a script and commit it. This could be a schema change, data change or a settings change you make in the interface of your app (like you do in Drupal). It can be quite hard to get into the habit but it becomes natural after a while.
On Windows use a .bat file containing this:
mysqldump -u USERNAME -pPASSWORD ––add-drop-table DBNAME >db.sql
(that’s no space between p and the password)
This will dump to a file called db.sql. On *nix you need to give the file execute permissions.
Now when you restore an old revision you can also restore the database with:
mysql -u USERNAME -p DBNAME <db.sql
It will ask you for the password. Or do it phpmyadmin. It’s often best to do it on the command line when the database is big (i.e. over a couple of Mb).