-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinit-database.sh
More file actions
36 lines (34 loc) · 1.12 KB
/
init-database.sh
File metadata and controls
36 lines (34 loc) · 1.12 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
#!/bin/bash
echo "======================================="
echo "Initializing KnowChain Database..."
echo "======================================="
echo
echo "Please make sure MySQL is running on localhost:3306"
echo "Default root password will be used: 1234"
echo
read -p "Continue with database initialization? (Y/N): " confirm
if [[ "$confirm" != "Y" && "$confirm" != "y" ]]; then
echo "Database initialization cancelled."
exit 0
fi
echo
echo "Connecting to MySQL and creating database..."
mysql -u root -p123456 < "$(dirname "$0")/database/init.sql"
if [[ $? -eq 0 ]]; then
echo
echo "======================================="
echo "Database initialization completed successfully!"
echo "======================================="
echo "Database: knowchain"
echo "Test Users:"
echo " - admin / admin"
echo " - test / test"
echo "======================================="
else
echo
echo "ERROR: Database initialization failed!"
echo "Please check:"
echo "1. MySQL server is running"
echo "2. Root password is correct (123456)"
echo "3. MySQL client is available in PATH"
fi