一、自动备份:将以下代码保存为*.bat批处理脚本,然后再添加Windows定时作业,如每天凌晨2点执行:文章源自很文博客https://www.hinwi.com/很文博客-https://www.hinwi.com/15421.html
set s=%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%文章源自很文博客https://www.hinwi.com/很文博客-https://www.hinwi.com/15421.html
mysqldump -u root -ppassword databasename > d:\databasename_%s%_bak.sql文章源自很文博客https://www.hinwi.com/很文博客-https://www.hinwi.com/15421.html
说明:databasename 为数据库名 password为数据库密码,系统自动以当前日期时间备份至指定目录。文章源自很文博客https://www.hinwi.com/很文博客-https://www.hinwi.com/15421.html
二、还原数据库: mysql -u root -p databasename <d:\databasename.sql文章源自很文博客https://www.hinwi.com/很文博客-https://www.hinwi.com/15421.html 文章源自很文博客https://www.hinwi.com/很文博客-https://www.hinwi.com/15421.html
评论