Docker installation and removal of Mysql5.7

Install Mysql

  1. View local mirror

docker images

At this time, there is no Mysql image in the container

  1. Pull Mysql image

docker pull mysql:5.7

  1. Run the MySQL container

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

If the local system does not have Mysql installed, then just enter the following code directly: (here 123456 is a custom password)

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

  1. View running containers

docker ps -a
  1. Enter the MySQL container

docker exec -it mysql5.7 /bin/bash

Execute the following code, enter the password and press Enter

mysql -u root -p

Operate the database

Exit command:

remove mysql

  1. view container

docker ps -a

Find the container id of mysql

  1. stop container

docker stop xxx
  1. delete container

docker rm xxx
  1. view mirror

docker images
  1. delete mirror

docker rmi 镜像id

Guess you like

Origin blog.csdn.net/qq_44936392/article/details/128935294