forked from FacuMasino/bancar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_scripts.bat
71 lines (60 loc) · 2.35 KB
/
run_scripts.bat
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
@echo off
setlocal enabledelayedexpansion
REM Directorio base de instalación de MySQL
set "mysqlDir=C:\Program Files\MySQL"
REM Variable para guardar la ruta de MySQL encontrada
set "mysqlBin="
REM Busca carpetas que empiecen con "MySQL Server" y luego obtiene la más reciente
for /d %%D in ("%mysqlDir%\MySQL Server *") do (
set "mysqlBin=%%D\bin"
)
REM Si se encontró una carpeta, agregarla al PATH
if defined mysqlBin (
echo Ruta de MySQL encontrada: %mysqlBin%
set "PATH=%mysqlBin%;%PATH%"
) else (
echo No se encontró ninguna instalación de MySQL.
)
:menu
echo Choose database host:
echo.
echo 1- Default localhost
echo 2- Localhost with custom password
echo.
set /p choice=Enter your choice (1 or 2):
if "%choice%"=="1" (
set database_host="localhost"
set database_user="root"
set database_pass="root"
) else if "%choice%"=="2" (
set database_host="localhost"
set database_user="root"
set /p database_pass=Enter database password:
) else (
echo Invalid option. Please try again.
goto menu
)
cls
echo.
echo The selected host data is: %database_host%
echo.
echo Do you really want to overwrite the current database?
echo.
set /p confirm=Enter your choice (Y/N):
if /i "%confirm%" NEQ "Y" (
echo Cancelled by user.
pause
goto menu
)
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < delete_database.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < create_database.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < collate_UTF8.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < create_tables.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < create_functions.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < create_stored_procedures.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < create_views.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < insert_initial_data.sql
mysql -h %database_host% -u %database_user% -p%database_pass% --default-character-set=utf8mb4 < insert_dummy_data.sql
echo.
echo "Database reset complete."
pause