The sister asked me today [How to use docker to install mysql in Linux]

Use docker to install mysql in Linux

Install docker

installation steps

The following operations are based on CentOS 7

1. Install some necessary system tools

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Insert picture description here


Insert picture description here

2. Add software source information

sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Insert picture description here

3. Update and install Docker-CE

sudo yum makecache fast
sudo yum -y install docker-ce
Insert picture description here


Insert picture description here
Insert picture description here

4. Turn on the Docker service

sudo service docker start
Insert picture description here

Installation verification

docker version
Insert picture description here
At this point, the docker installation is complete, and then
start to install mysql.

Install mysql

Pull the mirror of mysql

docker pull mysql:5.7.34
Insert picture description here

Check whether the pull is successful

docker images
Insert picture description here

Configure mysql

docker run --name mysql -p 4306:3306  -e MYSQL_ROOT_PASSWORD=root -d  mysql:5.7.34  --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
Insert picture description here

View configuration information

docker ps
Insert picture description here

Test connection to mysql

First check the virtual machine ip

ip addr
Insert picture description here

Use SQLyog to connect to mysql in Linux

Insert picture description here


Insert picture description here


connection succeeded:

Insert picture description here
OK, this is the end. This time, I helped the senior sister to solve the problem of how to use docker to install mysql in Linux. The senior sister looked at me with admiration [haha]
The above is the whole content of the school sister even asked me today [How to use docker to install mysql in Linux].

After reading, if it is helpful to you, thank you for your support!
If you are on a computer, you will see "One key triple connection"Are you done, right click on it [haha]

Insert picture description here


Come on!

Work together!

Keafmd