Home  >  Article  >  Database  >  Mysql自动备份与还原方法

Mysql自动备份与还原方法

WBOY
WBOYOriginal
2016-06-07 18:04:01874browse

Mysql自动备份与还原方法,需要的朋友可以参考下。

一、自动备份:将以下代码保存为*.bat脚本,然后再添加Windows定时作业,如每天凌晨2点执行:
set s=%date:~0,4%%date:~5,2%%date:~8,2%%time:~1,1%%time:~3,2%%time:~6,2%
mysqldump -u root -ppassword databasename > d:\databasename_%s%_bak.sql

说明:databasename 为数据库名 password为数据库密码,系统自动以当前日期时间备份至指定目录。

二、还原数据库: mysql -u root -p databasename
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn