Install MySQL 5.7 on Ubuntu 20.04

First follow installation instructions given at .

Then make sure docker is running properly:

$ sudo docker run hello-world

Ensure it created the image by:

$ sudo docker images

Now, install docker MySQL 5.7 image and create a volume for storing data.

$ sudo docker pull mysql/mysql-server:5.7
$ sudo docker volume create mysql-volume

Make a MySQL installation with command:

$ sudo docker run -d --restart unless-stopped --name=mysql -p3306:3306 -v mysql-volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password -d mysql/mysql-server:5.7

Replace the password with your one.

To show running instances:

$ sudo docker ps

Login to docker instance terminal:

$ sudo docker exec -it mysql bash

Now login to MySQL:

$ mysql -u root -p

Allow to access MySQL from everywhere as root user. CAUTION: It is not good to do it on serious or production servers:

> CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass';

Exit out of both MySQL and docker terminals.

On you host system. Install mysql-client program then you can access the MySQL server with:

$ mysql -h -u root -p

Leave a Reply

Your email address will not be published. Required fields are marked *