简体   繁体   中英

How to backup my MySQL's databases on Windows Vista?

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.

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.

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

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.

您也可以浏览localhost / phpmyadmin并转到“导出”,然后选择要导出的数据库。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM