Install Mysql
View local mirror
docker images
At this time, there is no Mysql image in the container
Pull Mysql image
docker pull mysql:5.7
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
View running containers
docker ps -a
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
view container
docker ps -a
Find the container id of mysql
stop container
docker stop xxx
delete container
docker rm xxx
view mirror
docker images
delete mirror
docker rmi 镜像id