How to Run MySQL 5.7.13 in Docker: A Quick, Isolated Setup Guide
Learn how to quickly set up an isolated MySQL 5.7.13 instance using Docker containers, covering environment installation, image pulling, container launch with port mapping, copying the MySQL package, installing inside Ubuntu, and connecting from the host, all without affecting existing services.
Previously I experimented with MySQL 5.7.13, but installing another version on a machine that already had MySQL was cumbersome, so I chose Docker containers for a simpler solution.
Running multiple versions of software (JDK, Redis, etc.) on a single host often leads to conflicts and maintenance difficulties; virtual machines solve this but are heavyweight.
Docker containers provide a lightweight, fast‑starting, isolated environment similar to a virtual machine, allowing many independent services on one machine.
For instance, a server already running Redis 2.8 and MySQL 5.6 can test newer versions in separate Docker containers without affecting each other.
(1) Install Docker environment – Docker provides installers for Windows, Linux and macOS.
(2) Pull a base image – For example, obtain an Ubuntu image:
docker pull ubuntu(3) Start the container – Launch Ubuntu and map host port 3307 to the container’s MySQL port 3306:
After the container starts, you can enter its shell (e.g., [root@container /]#) and perform normal operations.
(4) Copy the MySQL package into the container – Download MySQL 5.7.13 on the host and use Docker’s copy command to transfer it.
(5) Install and run MySQL inside the container – Execute the usual MySQL installation steps in the Ubuntu shell, then start the server and create a remote‑access user (e.g., test / 111111).
(6) Connect from the host – Use a MySQL client on the host with the following credentials: host – Docker‑assigned IP, username – test, password – 111111, port – 3307.
This completes a fully isolated MySQL installation using Docker, illustrating a simple yet powerful use case of container technology.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
