批量执行sql脚本

  sre

@echo off
@set db= authplat_public
@set ip= localhost
@set port= 3306
@set userName=authplat_public
@set password=kefXZQOe1wXjNcTc
@set msgLog=msgLog.log
@set errLog=errLog.log
for /r E:/sql %%i in (*.sql) do (
echo excute %%i start>>%msgLog%
echo excute %%i start>>%errLog%
echo.>>%errLog%
mysql -f -h%ip% -P%port% -u%userName% --password=%password% %db% < %%i --default-character-set=UTF8 1>>%msgLog% 2>>%errLog%
echo excute %%i end>>%msgLog%
echo.>>%errLog%
echo excute %%i end>>%errLog%
)
echo SQL excute end>>%msgLog%
pause

LEAVE A COMMENT

Captcha Code