test / init-db.sh
stat-utas's picture
Create init-db.sh
398df76 verified
Raw History Blame Contribute Delete
451 Bytes
#!/bin/bash
set -e
# Initialize the database
mysqld --initialize-insecure --user=mysql
# Start MariaDB in the background
mysqld_safe &
sleep 10
# Create the database and user
mysql -e "CREATE DATABASE IF NOT EXISTS moodle;"
mysql -e "CREATE USER IF NOT EXISTS 'moodleuser'@'%' IDENTIFIED BY 'moodlepassword';"
mysql -e "GRANT ALL PRIVILEGES ON moodle.* TO 'moodleuser'@'%';"
mysql -e "FLUSH PRIVILEGES;"
# Shut down the server
mysqladmin shutdown