Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install mysql 8.0 on ubuntu 18.04
#!/bin/bash
apt-get update
apt-get install -y debconf libaio1 apparmor-profiles lsb-release gnupg
DEB="/tmp/mysql.deb"
ROOT_PASSWORD=""
MYSQL_USER="testuser"
MYSQL_PASSWORD="testpass"
curl -H "UserAgent: Mozilla" -L -o $DEB https://dev.mysql.com/get/mysql-apt-config_0.8.15-1_all.deb
export DEBIAN_FRONTEND="noninteractive"
echo "mysql-apt-config mysql-apt-config/select-server select mysql-8.0" | debconf-set-selections
dpkg -i ${DEB}
apt-key adv --keyserver pgp.mit.edu --recv-keys 5072E1F5 || true
debconf-set-selections <<< "mysql-server mysql-server/root_password password ${ROOT_PASSWORD}";
debconf-set-selections <<< "mysql-server mysql-server/root_password_again password ${ROOT_PASSWORD}";
apt-get update
apt-get install -y mysql-server
systemctl start mysql
mysql -u root --password=${ROOT_PASSWORD} -e "CREATE USER ${MYSQL_USER}@'%' identified by '${MYSQL_PASSWORD}'; GRANT ALL PRIVILEGES ON *.* TO ${MYSQL_USER}@'%'; FLUSH PRIVILEGES;"
rm -f ${DEB}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment