Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MySQL 8 Installation - Ubuntu 18.04 / 20.04 LTS
#!/usr/bin/env bash
password="root"
echo PURGE | sudo debconf-communicate mysql-community-server
sudo apt purge mysql-client mysql-server
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $password"
sudo debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $password"
sudo debconf-set-selections <<< "mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)"
sudo apt install -y dirmngr
sudo apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 5072E1F5
echo "deb http://repo.mysql.com/apt/ubuntu $(lsb_release -sc) mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql80.list
sudo apt-get update
export DEBIAN_FRONTEND="noninteractive"
sudo apt-get install mysql-server
@jessuppi

This comment has been minimized.

Copy link

@jessuppi jessuppi commented Jul 22, 2020

@ziadoz Thanks for sharing this! I started wondering if purging debconf values beforehand was a good idea... but haven't seen anyone else suggest doing it this way. I've added your Gist to our references in SlickStack:

https://github.com/littlebizzy/slickstack/blob/master/ss-install-mysql.txt

@ziadoz

This comment has been minimized.

Copy link
Owner Author

@ziadoz ziadoz commented Jul 23, 2020

@jessuppi Glad you found this useful. Purging the debconf values isn't necessary, I just like to start from a clean slate when doing installations like this really.

@jessuppi

This comment has been minimized.

Copy link

@jessuppi jessuppi commented Jul 23, 2020

Makes sense, @ziadoz. Better to make sure there's no conflicts. By the way, I had to add more sudos to make this work in our current script although I'm not sure why a similar variation previously worked without those on Ubuntu 18.04 + MySQL 5.7:

sudo echo "mysql-community-server mysql-community-server/root-pass password ${DB_PASSWORD_ROOT}" | sudo debconf-set-selections
sudo echo "mysql-community-server mysql-community-server/re-root-pass password ${DB_PASSWORD_ROOT}" | sudo debconf-set-selections
sudo echo "mysql-community-server mysql-server/default-auth-override select Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)" | sudo debconf-set-selections

...perhaps related to the new default authentication stuff in MySQL 8.0, I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.