Last active
February 22, 2019 10:34
-
-
Save itsterry/3dc30ff69878372208ce89c47d922693 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
data_dir="/usr/data" | |
function prepare-data-dir(){ | |
echo "* Preparring data directory" | |
sudo mkdir $data_dir | |
sudo chown mysql:mysql $data_dir | |
} | |
function install-mysql(){ | |
echo "* Installing MySQL 5.7 from PPA" | |
echo "deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-5.7" | sudo tee /etc/apt/sources.list.d/mysql57.list | |
install-package --update-new mysql-server -o Dpkg::Options::="--force-confnew" | |
} | |
function upgrade-system-tables(){ | |
echo "* Running MySQL system upgrade" | |
# remove to avoid loading rogue sql modes | |
sudo rm -f /usr/my.cnf | |
mysql_upgrade -u ${DATABASE_MYSQL_USERNAME} -p${DATABASE_MYSQL_PASSWORD} --force | |
sudo service mysql restart | |
} | |
function print-active-sql-modes(){ | |
mysql -u ${DATABASE_MYSQL_USERNAME} -p${DATABASE_MYSQL_PASSWORD} -e "show variables like 'sql_mode'" | |
} | |
function main(){ | |
prepare-data-dir | |
install-mysql | |
upgrade-system-tables | |
print-active-sql-modes | |
echo "* Installation complete" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment