-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-db.sh
executable file
·34 lines (28 loc) · 941 Bytes
/
setup-db.sh
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
#!/bin/bash
# Function to check if MariaDB is installed
is_mariadb_installed() {
dpkg -s mariadb-server &> /dev/null
}
# Check if MariaDB is installed
if is_mariadb_installed; then
echo "MariaDB is already installed."
else
echo "Installing MariaDB server..."
sudo apt-get update
sudo apt-get install mariadb-server mariadb-client -y
fi
# Start MariaDB service
sudo service mysql restart
# Optionally, secure the MariaDB installation
# Uncomment the next line to run the secure installation
# sudo mysql_secure_installation
# Create database and user
sudo mysql -uroot -Bse "
CREATE DATABASE sakaidb DEFAULT CHARACTER SET utf8;
CREATE USER 'sakaiuser'@'localhost' IDENTIFIED BY 'sakaipassword';
GRANT ALL ON sakaidb.* TO 'sakaiuser'@'localhost';
CREATE USER 'sakaiuser'@'127.0.0.1' IDENTIFIED BY 'sakaipassword';
GRANT ALL ON sakaidb.* TO 'sakaiuser'@'127.0.0.1';
FLUSH PRIVILEGES;
"
echo "Database setup complete."