@ECHO off
chcp 65001
echo 启动sql控制脚本

echo "1| 保存sql   2| 运行sql覆盖数据库"


set /p var="请输入控制指令 :"
echo  %~dp0
C:
cd C:\Program Files\MySQL\MySQL Server 5.7\bin\
SET dbhost=127.0.0.1
SET dbuser=root
SET dbpasswd=root
SET dbName=virtual_mall

echo 当前控制的mysql和数据库是 :[%dbhost%]%dbuser%@%dbpasswd%/%dbName%
echo "code %var%"

if %var% == 1 (
echo [%time%] [保存sql]
mysqldump -h%dbhost% -u%dbuser% -p%dbpasswd% %dbName% > %~dp0\virtual_mall.sql
) else if %var% == 2 (
echo [%time%] [运行sql]
mysql -h%dbhost% -u%dbuser% -p%dbpasswd% %dbName% < %~dp0\virtual_mall.sql
) else (
echo "运行错误 未知代码:%var%"
)
@echo on