<>linux Under the use of docker install mysql

<> get ready :

* centOs7 linux system
<>1, install docker

* yum install docker
// Install the latest version of docker

* systemctl start docker
// start-up docker

* yum -y remove docker
// delete docker

<>2, install mysql

* docker pull mysql
// Pull mysql image

* docker image
// see docker Local library

4. docker run --name mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d mysql

// Create and start a MySQL container

-name : The name of the container , It's called mysql
-e Configure account password , Here is root account , The password is root
-p Port mapping , Native 3306 Of the port mapping container 3306 port
-d Output the container's id
final mysql Indicates that the image name is mysql

* docker ps
// List container list

5. Test connection database
1.firewall-cmd --zone=public --add-port=3306/tcp --permanent // Open port
2.firewall-cmd --reload // Reload 3. use nvaicat Connection test

<> other

1.docker exec -it mysql /usr/bin/bash

get into mysql Container configuration and other operations

Technology