-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathmysql.sh
More file actions
executable file
·17 lines (15 loc) · 1014 Bytes
/
mysql.sh
File metadata and controls
executable file
·17 lines (15 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
source load_config.sh
echo "-------------------------------------------------------------"
echo "Setup the Mariadb server (MYSQL)"
echo "-------------------------------------------------------------"
sudo apt-get install -y mariadb-server mariadb-client
# Secure mysql
echo "-- Secure MYSQL"
sudo mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DELETE FROM mysql.user WHERE User=''; DROP DATABASE IF EXISTS test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'; FLUSH PRIVILEGES;"
# Create the emoncms database using utf8 character decoding:
echo "-- Create $mysql_database database"
sudo mysql -e "CREATE DATABASE $mysql_database DEFAULT CHARACTER SET utf8;"
# Add emoncms database, set user permissions
echo "-- Add user:$mysql_user and assign to database:$mysql_database"
sudo mysql -e "CREATE USER '$mysql_user'@'localhost' IDENTIFIED BY '$mysql_password'; GRANT ALL ON $mysql_database.* TO '$mysql_user'@'localhost'; flush privileges;"