MySQL AWS Ubuntu Install Script in Shell

#!/bin/bash # Set up our command aliases . /home/ubuntu/_install/sh/ if [ ! -d /tmp/import/ ] then sudo mkdir /tmp/import fi sudo chown -R mysql:mysql /tmp/import/ sudo chmod 777 -R /tmp/import/ _update echo 'mysql-server mysql-server/root_password password PASSWORD_HERE' | sudo debconf-set-selections echo 'mysql-server mysql-server/root_password_again password PASSWORD_HERE' | sudo debconf-set-selections _install mysql-server mysql-client # Bounce apache only if it's running SERVICE='apache' if ps ax | grep -v grep | grep $SERVICE > /dev/null then _bounce_web fi _update # Make prod DB mysql -uroot -pPASSWORD_HERE -e "USE mysql; UPDATE user SET Host='%' WHERE User='root' AND Host='localhost';" mysql -uroot -pPASSWORD_HERE -e "flush privileges;" mysql -uroot -pPASSWORD_HERE -e "CREATE DATABASE IF NOT EXISTS prod;" mysql -uroot -pPASSWORD_HERE prod < default.sql /* for remote access the line that starts with bind-address need to be commented in /etc/mysql/my.cnf */ sudo sed -i 's/bind-address/\#bind-address/g' /etc/mysql/my.cnf sudo service mysql restart echo 'phpmyadmin phpmyadmin/dbconfig-install boolean true' | debconf-set-selections echo 'phpmyadmin phpmyadmin/app-password-confirm password PASSWORD_HERE' | debconf-set-selections echo 'phpmyadmin phpmyadmin/mysql/admin-pass password PASSWORD_HERE' | debconf-set-selections echo 'phpmyadmin phpmyadmin/mysql/app-pass password PASSWORD_HERE' | debconf-set-selections echo 'phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2' | debconf-set-selections _install phpmyadmin

"PASSWORD_HERE" and DB name from "prod" if you want...

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.