备份远程mysql库

备份远程mysqk库,导入到本地数据库。 数据库名为当前日期+时间。

BAT FILE

@echo off
set now=fsdex
FOR /F "tokens=1,2,3 delims=- " %%i in ("%date%/T") do set now=%now%%%i%%j%%k
rem echo %now%

FOR /F "tokens=1,2,3 delims=:. " %%i in ("%time%") do set now=%now%_%%i%%j%%k
rem echo %now%

set dbname=%now%
D:
cd "=dev="/mysql/bin

echo 创建数据库%dbname%,请输入localhost密码...
mysqladmin -h localhost -u fsdex -p create %dbname%

echo 备份开始,请依次输入remote/localhost数据库密码并回车...
mysqldump --opt -h xxx.xxx.xxx.xxx fsdex -u fsdex -p | mysql -u fsdex -p %dbname%

echo 备份完毕pause

相关文章
相关标签/搜索