MySQL supports command line import Export data file, format is *.sql
1) Import:
Mysql-u User name-p password database name < file path \ filename
2) Export:
Mysqldump-u User name-p password Database name > file path \ filename
3) Real case
I am on the Windows 2003 Development Server, the implementation of a timed automatic backup
Generic filename, used by date and time. sql. Here's my *.bat batch file
A total of 3 lines:
First line, which means switch to D disk
The second line, locate the MySQL installation directory's Bin directory, so you do not need to set environment variables
The third line, export the *.sql file and use the current time as the filename, in the following format: Cold_20101026_1244.sql, representing the cold database, the backup file generated at 12:44 noon on October 26, 2010
D:
CD D:\Program files\mysql\mysql Server 5.1\bin
mysqldump-uroot-p123456 Cold > D:\mysql_data\cold_%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%.sql
Then, add the batch file to the Windows Task plan.
Click Control Panel > Task Scheduler > Add Task Schedule.
By the way to restore the code, to restore the time to manually build the database, by default, is not automatically create the database
D:
CD D:\Program files\mysql\mysql Server 5.1\bin
mysql-uroot-p147258369 Cold < D:\mysql_data\cold_20101026_1234.sql
The rest is done by following the wizard. My solution is not the best solution, just a common practice, Oracle Backup, you can do so, cross-platform, you need to add the script to the task plan.