If the goal is to use a previous version of MySQL on a current release of Ubuntu, the two options that I have found to be most reliable are:
- Creating a dedicated Virtual Machine for that software
- Using a Docker container for that software
The nice thing about Virtual Machines is that they operate just like a regular Ubuntu installation and all of the skills you already know can transfer over just fine. The downside is that they generally require more resources to be dedicated to them.
The nice thing about Docker containers is that you can very quickly set up a specific version of software without first going through the process of obtaining an older Ubuntu ISO and setting everything up.
Here is how you can get MySQL 5.7 running with either option:
Installing MySQL 5.7 on a Virtual Machine
- Download and install VirtualBox if you do not already have it on your system
- Download the ISO for Ubuntu Server 16.04.7, which uses the MySQL 5.7 release by default (unless you manually override it to use MySQL 8.0)
- Create an Ubuntu VM in VirtualBox, ensuring the VM is accessible to the host machine (or the local network)
- Install MySQL with:
$ sudo apt update
$ sudp apt install mysql-server
- Use the machine
Installing MySQL 5.7 via Docker
First, if you don't already have Docker installed on your system, let's get Docker:
- Open a Terminal and ensure the basics are installed:
$ sudo apt update
$ sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
- Add Docker's GPG key to your system:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add the Docker software repository:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Install the Docker Engine:
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
- Make sure the tool functions by running the "Hello World" container:
$ sudo docker run hello-world
Now that Docker is installed, let's get MySQL 5.7 ...
- Pull the MySQL 5.7 container from Docker:
$ sudo docker pull mysql/mysql-server:5.7
- Run the container:
sudo docker run –name=mysqlCon -p 3306:3306 -d mysql/mysql-server:5.7
Note: the -p
sets the port you wish to communicate on. 3306 is the default for MySQL.
- Get the default
root
password for the MySQL server:
sudo docker logs mysqlCon
You'll see a line that looks like:
[Entrypoint] GENERATED ROOT PASSWORD {password}

- Connect to the MySQL instance on Docker:
sudo docker exec -it mysqlCon mysql -uroot -p
Note: The above command will SSH into the container and run the mysql
command. You'll be asked for the generated password.
- Set your own password:
ALTER USER 'root'@'localhost' IDENTIFIED BY 'CorrectHorseBatteryStaple';
Be sure to set a proper password for your installation.
- Start using MySQL.
This looks like a lot of steps but, once you see the flexibility of using VMs or Docker containers to work with very specific versions of software, you'll wonder how you ever did without.
Hope this gives you what you need.