-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-database.bat
More file actions
77 lines (66 loc) · 2.1 KB
/
setup-database.bat
File metadata and controls
77 lines (66 loc) · 2.1 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@echo off
REM Customer Management System Database Setup
REM This batch file sets up the database for the application
echo ========================================
echo Customer Management System Database Setup
echo ========================================
echo.
REM Set variables
set MYSQL_PATH=C:\Program Files\MariaDB 12.1\bin\mysql.exe
set DB_USER=root
set DB_NAME=customer_management_db
set PROJECT_DIR=e:\MY PROJECTS\Customer_Management_System
echo.
echo Please enter MariaDB root password (or press Enter if no password):
set /p DB_PASS=Password:
echo Checking if MySQL exists...
if not exist "%MYSQL_PATH%" (
echo Error: MySQL not found at %MYSQL_PATH%
echo Please install XAMPP or update the path
pause
exit /b 1
)
echo OK - MySQL found
echo.
echo Step 1: Creating database and user...
(
echo CREATE DATABASE IF NOT EXISTS %DB_NAME% CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
echo DROP USER IF EXISTS 'cms_user'^@'localhost';
echo CREATE USER 'cms_user'^@'localhost' IDENTIFIED BY 'cms_pass';
echo GRANT ALL PRIVILEGES ON %DB_NAME%.* TO 'cms_user'^@'localhost';
echo FLUSH PRIVILEGES;
) | "%MYSQL_PATH%" -u %DB_USER% %if "%DB_PASS%"=="" echo "else echo -p%DB_PASS%"%
if errorlevel 1 (
echo Failed to create database
pause
exit /b 1
)
echo OK - Database created
echo.
echo Step 2: Creating tables...
"%MYSQL_PATH%" -u cms_user -pcms_pass %DB_NAME% < "%PROJECT_DIR%\backend\src\main\resources\schema.sql"
if errorlevel 1 (
echo Failed to create tables
pause
exit /b 1
)
echo OK - Tables created
echo.
echo Step 3: Loading sample data...
"%MYSQL_PATH%" -u cms_user -pcms_pass %DB_NAME% < "%PROJECT_DIR%\backend\src\main\resources\data.sql"
if errorlevel 1 (
echo Warning: Could not load sample data
) else (
echo OK - Sample data loaded
)
echo.
echo ========================================
echo Database setup completed successfully!
echo ========================================
echo.
echo Next steps:
echo 1. Start Backend: cd backend ^& mvn spring-boot:run
echo 2. Start Frontend: cd frontend ^& npm start
echo 3. Open: http://localhost:3000
echo.
pause