Upgrade MySQL from 5.7 to 8 on Ubuntu

Step 1. Add MySQL APT repository

wget https://repo.mysql.com/mysql-apt-config_0.8.16-1_all.deb

sudo dpkg -i mysql-apt-config_0.8.16-1_all.deb

Step 2. Update APT index and install MySQL server

$ sudo apt-get update
$ sudo apt-get install mysql-server

Confirm installation:

CREATE USER ‘root’@’%’ IDENTIFIED BY ‘root’;
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ WITH GRANT OPTION;
FLUSH PRIVILEGES;

CREATE USER ‘foo’@’localhost’ IDENTIFIED BY ‘bar’;
GRANT ALL PRIVILEGES ON database_name.* TO’foo’@’localhost’;

CREATE USER ‘foo’@’%’ IDENTIFIED BY ‘bar’;
GRANT ALL PRIVILEGES ON database_name.* TO’foo’@’%’;
FLUSH PRIVILEGES;