Using multiple MySQL versions on the same linux machine using docker
We had a card that described how to install multiple mysql versions using
mysql-sandbox. Nowadays with the wide adoption of docker it might be easier to use a MySQL docker image for this purpose.
docker run --name projectname_db -e MYSQL_ROOT_PASSWORD=secret -p "33008:3306" -d --restart unless-stopped mysql:5.7
The port 33008 is a freely chosen free port on the host machine that will be used to establish a connection.
You can see available mysql versions on .
The restart policy
unless-stopped will also start the database container after a reboot (until you manually stop it).
$ mysql -uroot -psecret -P 33008 -h 127.0.0.1 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.35 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]>
Make sure to always use the ip instead of localhost (
-h 127.0.0.1) so that a tcp connection is used instead of a socket connection.
development: adapter: mysql2 database: projectname_development encoding: utf8mb4 collation: utf8mb4_unicode_ci host: 127.0.0.1 username: root password: secret port: 33008 variables: sql_mode: TRADITIONAL
docker stop projectname_db # stop the container docker start projectname_db # start the container e.g. after a reboot docker rm projectname_db # remove the container (will not delete the volume of the container) docker volume prune # remove the volume (and all other volumes that are not connected to a container) docker rm -v projectname_db # remove the container including volume in one step