views:

34

answers:

4

Hello.

How can I backup my MySQL's databases? I'm using Windows Vista and MySQL 5.1.

I have found the folder "C:\Users\All Users\MySQL\MySQL Server 5.1\data" with all my database files and copy them, but how can I restore them if I need?

Thank you.

+1  A: 

The backup process does not have anything to do with your operating system. Simply export your databases.

thelost
+2  A: 

You could use the mysqldump tool:

http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

That way you'd get SQL files that you could just execute.

Paul
+1  A: 

You can back up the database files directly, but this can be dangerous if the database is in active use at the time you do the backup. There's no guarantee that you'll make a consistent and valid backup if a query starts modifying on-disk data. You may end up with broken tables.

The safest route is to use mysqldump to output a set of sql statements which can recreate the database completely (table creation + data) in one go. Should you need to restore from backup, you can simply feed this dump file back to mysql:

mysqldump -p -u username nameofdatabase > backup.sql

and restore via:

mysql -p -u username nameofdatabase < backup.sql

The .sql file is just a plaintext dump of all the queries required to rebuild the table(s) and their data.

Marc B
+1  A: 

You can also go surf to localhost/phpmyadmin and go to 'export' and select the databases you want to export.