СHRISTMAS
WHEEL OF FORTUNE

Tap the button and win a guaranteed prize right now!

By registering, you are signing up to receiving e-mails.
JT
January 30 2024
Updated January 26 2024

How to set up MySQL on Docker?

Databases

In the realm of database management, Docker has emerged as a game-changer, providing a streamlined and efficient approach to setting up and running databases. This tutorial focuses on MySQL installation through Docker—a method favored by developers and DevOps professionals. Much like the advantages it offers for MongoDB, leveraging Docker for MySQL installation brings unprecedented benefits in terms of portability, scalability, and isolation.

Installation MySQL on Docker

At the start of installation process we update indexes and upgrade packages of currently application and utility. That help to avoid potential compatibility issues :

apt update && apt upgrade -y
Update package
Screenshot №1 — Update package

At the end of the process make sure that process was completed successfully and no one issues was pop-uped. Next stage, will installation software for containerization application, by the command below:

apt install docker.io
Installation of Docker
Screenshot №2 — Installation of Docker

Docker represent platform for start isolated application, utility or system with integrated file-system, network and kit-tools for properly work. We can download from repository image and install them into the container, in isolated part! And connect to them we can through localhost and indicated port or literally use straight connection via terminal. After installation docker, we can download and automatically deploy server MySQL, by the command:

docker run --name my-db -e MYSQL_ROOT_PASSWORD=123321 -d mysql
Pull package
Screenshot №3 — Pull packages

Checking the installation of MySQL on Docker

Alright, now we need to make sure that our Docker container was created and upped, for that we can use command:

docker ps
Process
Screenshot №4— Process

If you have any issues you can type command below for check log container and troubleshoot them:

docker logs my-db
logs
Screenshot №5— Logs

Now, we can connect to the container via network and indicate credentials, for manage with utility:

docker exec -it my-db bash

And after that command we can start our DB using appropriate utility:

mysql -h localhost -u root -p
Connection
Screenshot №6— Connection

Alright! Our connection was established and we can use them from their client.

In this comprehensive exploration of usage Docker for MySQL, we've navigated the transformative landscape of database management, where Docker emerges as a pivotal force. Developers and DevOps professionals increasingly favor this approach for MySQL setup, drawing parallels with the efficiency seen in MongoDB deployments. Leveraging Docker for MySQL not only simplifies the installation process but also introduces unmatched benefits in terms of portability, scalability, and isolation.

Vote:
5 out of 5
Аverage rating : 5
Rated by: 1
33145 North Miami, FL 2520 Coral Way apt 2-135
+1 302 425-97-76
700 300
ITGLOBAL.COM CORP
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.