## Checklist

[ ] sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
[ ] Install locate search: sudo apt install locate
[ ] Update locate database: sudo updatedb
[ ] Install MariaDB: sudo apt install mariadb-server
[ ] Check MariaDB status: sudo systemctl status mariadb
[ ] Stop MariaDB : sudo systemctl stop mariadb
[ ] Create a databases folder in /mnt/data: sudo mkdir /mnt/data/databases
[ ] Copy MariaDB DB's to /mnt/data: sudo rsync -av /var/lib/mysql /mnt/data/databases
[ ] Rename old database folder until setup finished and tested to remove confusion: sudo mv /var/lib/mysql /var/lib/mysql.bak
[ ] Make a log directory on /mnt/log: sudo mkdir -m 2755 /mnt/log/maria_log
[ ] Change owner of log folder to mysql (maria user) /mnt/log/maria_log: sudo chown mysql /mnt/log/maria_log
[ ] Make a temp directory on /mnt/log: sudo mkdir /mnt/log/tmp
[ ] Change owner of temp folder to root : sudo chown root /mnt/log/tmp
[ ] Change rights on temp folder: sudo chmod 2755 /mnt/log/tmp
[ ] Change owner of tmp folder: sudo chown mysql /mnt/log/tmp
[ ] Open config file in Nano: sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
      - Uncomment #datadir and set the value to: /mnt/data/databases
      - Uncomment #tmpdir and set the value to: /mnt/log/tmp
      - Edit "bind address" value to: {server-ip}
      - Uncomment #log_error and set the value to: /mnt/log/maria_log/mariadb.err
      - IF DEVELOPMENT: Uncomment #slow_query_log_file and set the value to: /mnt/log/maria_log/maria-slow.log
      - IF DEVELOPMENT: Add log_slow_disabled_statements and set value to: 'admin,call,slave,sp'
      - IF DEVELOPMENT: Uncomment #log-queries-not-using-indexes and set value: ON
[ ] Start MariaDB : sudo systemctl start mariadb
      - If Mariadb fails to start: sudo mysql_install_db --user=mysql
      -- If this command fails run : sudo mysql_upgrade
[ ] Secure MariaDB configuration: sudo mysql_secure_installation
      - Switch to unix_socket authentication [Y/n]: n
      - Change the root password? [Y/n]: Y
      - Enter and confirm root password from Vault
      - Remove anonymous users? [Y/n]: Y
      - Disallow root login remotely? [Y/n]: Y
      - Remove test database and access to it? [Y/n]: Y if not DEV environment
      - Reload privilege tables now? [Y/n]: Y
[ ] Open local connection to MariaDB: sudo mariaDB
[ ] Create MariaDB User "db_user": CREATE USER 'db_user'@'%' IDENTIFIED BY '{Vault PASSWORD}';
[ ] Grant read\write privileges to db_user: GRANT SELECT, INSERT, UPDATE ON *.* TO 'db_user'@'%';
[ ] Grant execute privileges to db_user: GRANT EXECUTE ON *.* TO 'db_user'@'%';
[ ] Create MariaDB User "db_reader": CREATE USER 'db_reader'@'%' IDENTIFIED BY '{Vault PASSWORD}';
[ ] Grant read privileges to db_reader: GRANT SELECT ON *.* TO 'db_reader'@'%';
[ ] Grant execute privileges to db_reader: GRANT EXECUTE ON *.* TO 'db_reader'@'%';
[ ] Create MariaDB User "sa": CREATE USER 'sa'@'%' IDENTIFIED BY '{Vault PASSWORD}';
[ ] Grant ALL privileges to sa: GRANT ALL PRIVILEGES ON *.* TO 'sa'@'%';
[ ] Grant execute privileges to sa: GRANT EXECUTE ON *.* TO 'sa'@'%';
[ ] Push out privileges to users: FLUSH PRIVILEGES;
[ ] Snapshot (MariaDB installed & configured)
