MySQL - Running multiple version of mysql using Docker

I wrote these tutorials for myself in future when I forget for the next steps.
Search for a command to run...

I wrote these tutorials for myself in future when I forget for the next steps.
No comments yet. Be the first to comment.
When you provision an Ubuntu instance on Oracle Cloud, you'll notice something different from standard Ubuntu installations: the system uses iptables instead of ufw for firewall management. This disti

When developing web applications locally, HTTPS is often overlooked. Yet, modern browsers and APIs increasingly require secure connections—even in development. That’s where mkcert comes in: a simple t

Testing the checkout success page in Magento 2 can be frustrating. By default, once an order is placed, Magento clears the quote session, meaning you can’t simply refresh or revisit the success page without going through the entire checkout process a...

Magento Commerce (EE) offers powerful features, but for many teams, Open Source (CE) is leaner, lighter, and more sustainable. If you're migrating from EE to CE, the Opengento downgrade tool provides a clean, scriptable way to remove proprietary modu...

If you’ve ever checked your Apache error logs and seen something like this: Code [core:error] (13)Permission denied: access to /robots.txt denied (filesystem path '/home/username/sites') because search permissions are missing on a component of the pa...

In case to run multiple versions of MySQL, we can do in several ways. In this article, I'm going to run MySQL multiple versions using Docker & using MariaDB instead of mysql.
since we're going to use docker, of course we need to install docker. Please to follow official documentation by Docker to install on your machine.
You can choose between MySQL, MariaDB, or other version. in this case I'm going to use MariaDB, so I need to run this:
docker run -d --restart=always --name mariadb-10.4.20 --env MARIADB_ROOT_PASSWORD=root -p 1042:3306 mariadb:10.4.20
Descriptions:
--detach, -d Run container in background and print container ID
--restart Restart policy to apply when a container exits
--name Assign a name to the container
--env, -e Set environment variables
--expose, -p Expose a port or a range of ports
mariadb:10.4.20 Package-Name:version
3.1. How to ByPass password?
try to ssh on the running database by running:
docker exec -it mariadb-10.4.20 bash
then try to move to HOME directory by running
cd
and then add new file called .my.cnf, and the content are:
[client]
user=root
password=root
host=localhost
[mysqldump]
host=localhost
user=root
password=root
docker exec -it mariadb-10.2.44 mysql
Once you configured 3.1. you don't need to type the password.
docker exec -i mariadb-10.2.44 mysql -u user -p database_name < database.sql
Or if you want to have the progress bar whilst importing database, you can use this command: (don't forget to install pv if you don't have this package)
pv databse.sql | docker exec -i mariadb-10.2.44 sh -c 'mysql database_name'
docker exec -i mariadb-10.4.20 mysqldump database_name > database.sql
If you want to directly compress the file for the output, you can run this: (don't forget to install gzip if you don't have it.)
docker exec -i mariadb-10.4.20 mysqldump database_name | sed -e 's/\sDEFINER=`[^`]*`@`[^`]*`//g' | gzip -c > database.sql.gz
sed -e 's/\sDEFINER=`[^`]*`@`[^`]*`//g' -i database.sql