-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_db.ps1
More file actions
32 lines (25 loc) · 1.03 KB
/
setup_db.ps1
File metadata and controls
32 lines (25 loc) · 1.03 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
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host " Database Initialization" -ForegroundColor Cyan
Write-Host "=====================================" -ForegroundColor Cyan
Write-Host ""
$mysqlPath = "C:\Program Files\MariaDB 12.0\bin\mysql.exe"
$sqlFile = "C:\smallurl\backend\init_db.sql"
if (-not (Test-Path $mysqlPath)) {
Write-Host "Error: MySQL client not found at $mysqlPath" -ForegroundColor Red
exit 1
}
if (-not (Test-Path $sqlFile)) {
Write-Host "Error: SQL file not found at $sqlFile" -ForegroundColor Red
exit 1
}
Write-Host "Initializing database..." -ForegroundColor Yellow
Write-Host "Please enter your MySQL root password when prompted." -ForegroundColor Green
Write-Host ""
& $mysqlPath -u root -p -e "source $sqlFile"
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "Database initialized successfully!" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "Database initialization failed. Please check your password and try again." -ForegroundColor Red
}