1. First in a centos7 virtual machinedockerThe specific installation procedure refers to the
/engine/install/centos/
docker installationUpon completion, the container in which themysqlContainer installation, in fact, the mysql installed in this is again equivalent to a small linux. using thedocker commandsPull the mysql image online, you can select the corresponding version in the process of pulling, for example, you can also pull mysql:8.0
sudo docker pull mysql:5.7
Once the image pull is complete, use the appropriate docker commands to see if the image was pulled successfully.
sudo docker images
Run against the pulled image and set it up accordingly
-
docker run -p 3306:3306 --name mysql \
-
-v /mydata/mysql/log:/var/log/mysql \
-
-v /mydata/mysql/data:/var/lib/mysql \
-
-v /mydata/mysql/conf:/etc/mysql \
-
-e MYSQL_ROOT_PASSWORD=root \
-
-d mysql:5.7
Parameter description
-p 3306:3306 Maps the container's port 3306 to the host's port 3306
-v /mydata/mysql/log:/var/log/mysql \ Mount the configuration folder to the host computer
-v /mydata/mysql/data:/var/lib/mysql \ Mount the log folder to the host computer
-v /mydata/mysql/conf:/etc/mysql \ Mount the configuration folder to the host computer
-e MYSQL_ROOT_PASSWORD=root \ Initialize root user password
Use the appropriate commands to view the image after it has run successfully
sudo docker ps
After the mysql container in the docker container is successfully running, you can add a new file to thewindowsTo test whether mysql can be connected successfully, enter the ip address of the linux client and the corresponding information.
Stop all containers in docker using the command
docker stop $(docker ps -a -q)
Deleting containers from docker images by container's id
docker rmi <image id>
Delete all images in docker
-
docker rmi $(docker images -q)
-
Look inside the container
docker exec -it mysql /bin/bash
configuration file
-
[client]
-
default-character-set=utf8
-
-
[mysql]
-
default-character-set=utf8
-
-
[mysqld]
-
init_connect='SET collation_connection = utf8_unicode_ci'
-
init_connect='SET NAMES utf8'
-
character-set-server=utf8
-
collation-server=utf8_unicode_ci
-
skip-character-set-client-handshake
-
skip-name-resolve