Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[19e22f]: dist / restore / restore-mysql.bat Maximize Restore History

Download this file

restore-mysql.bat    49 lines (41 with data), 1.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@echo off
rem bbou@ac-toulouse.fr
rem 25/11/2013
set /P DB="Enter database name:"
set DBTYPE=mysql
set DBUSER=root
set /P DBPWD="Enter %DBUSER% password:"
set MODULES=wn legacy vn bnc sumo xwn glf ilfwn logs
call :dbexists
if not %DBEXISTS%==0 call :createdb
for %%M in (%MODULES%) do call :process %DBTYPE%-%%M-schema.sql "schema-%%M" %DB%
for %%M in (%MODULES%) do call :process %DBTYPE%-%%M-data.sql "data-%%M" %DB%
for %%M in (%MODULES%) do call :process %DBTYPE%-%%M-constrain.sql "constrain-%%M" %DB% --force
for %%M in (%MODULES%) do call :process %DBTYPE%-%%M-views.sql "views-%%M" %DB%
goto :eof
:process
setlocal
if not exist %1 goto :endprocess
echo %2
mysql -u %DBUSER% --password=%DBPWD% %4 %3 < %1
:endprocess
endlocal
goto :eof
:dbexists
setlocal
mysql -u %DBUSER% --password=%DBPWD% -e "\q" %DB% > NUL 2> NUL
endlocal & set DBEXISTS=%ERRORLEVEL%
goto :eof
:deletedb
setlocal
echo "delete %DB%"
mysql -u %DBUSER% --password=%DBPWD% -e "DROP DATABASE %DB%;"
endlocal
goto :eof
:createdb
setlocal
echo "create %DB%"
mysql -u %DBUSER% --password=%DBPWD% -e "CREATE DATABASE %DB% DEFAULT CHARACTER SET UTF8;"
endlocal
goto :eof
:eof