original Du Yishu
Previous stage experience MySQL new version 5.7.13, because there is already MySQL in the machine, install another version will have some trouble, in order to be simple, use the Docker container to install
Some people may think that there is no need to install multiple Mysql in a machine is not so complicated, indeed, the mere realization of this requirement is no problem, but in fact it is a universal demand
For example, a new version of the JDK, Redis out a new version, heard a new thing good ... All need to experience, the number of machines is limited, if all installed in a machine, there is a large probability of a puzzling problem, very difficult to maintain
The use of virtual machines can solve such problems, but the virtual machine is heavy, installation time-consuming, system resources occupy a lot
Docker containers are a great choice to be completely isolated from the host like a virtual machine, and the installation starts very fast, with fewer resources, and multiple containers can be run in one machine
For example, Redis 2.8 and Mysql 5.6 are already installed on the server, and now you want to test each new version and install it in a Docker container, independent of each other, without affecting each other.
Here's a look at how Mysql is installed and used in Docker, which, for ease of understanding, is analogous to the concept of virtual machines.
Note: The whole idea is introduced, not the detailed installation steps
(1) Installing the Docker environment
There are corresponding installers under Windows, Linux, and Mac
It's like installing VirtualBox in your own machine.
(2) get an image
For example, get an Ubuntu image from a mirrored warehouse
Docker pull Ubuntu
It's like installing an Ubuntu Linux system in VirtualBox.
(3) start the container
Can be understood as running Ubuntu in the VirtualBox.
To facilitate the subsequent connection of Mysql within the container in the host, you can specify a mapping port when you start the container, such as the 3307 Port of the host mapping to port 3306 in the container
Once the container is started, it can go into Ubuntu's shell for normal operation, such as
[Email protected]/]#
(4) copy the MySQL installation package into the container
Download the Mysql 5.7.13 installation package from the host and place it inside the container via the Docker copy command
(5) install and run Mysql in the container
Perform the MySQL installation operation under Ubuntu Shell normally, after the installation is complete, run MySQL
Then add a user that can be accessed remotely, such as test, password 111111
(6) connect Mysql in the host
Connect to the client using Mysql in the host, connection information:
Host-The IP assigned to Docker (available via Docker command)
Username-test
Password-111111
Port-3307
In this way, a completely independent Mysql is installed, this is just a simple application of Docker, Docker is very practical, now has a wide range of applications, will introduce more usages and cases
Docker container case: applying Mysql