Home>Article>Operation and Maintenance> How to run mysql on docker
How to run mysql on docker
The methods and steps for running the MySQL service on docker are as follows:
1. Pull the official mysql image from Docker Hub
docker pull mysql
Then there is a long wait. Of course, if you configure the image accelerator, the speed will be much faster
2. Use the docker images command to view the image
You will see that we already have the MySQL image here
3. Start our mysql Mirror, create a MySQL container
docker run -d --name mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
Parameter explanation:
-d means running in the background and not exiting with the exit of the current command line window
--name Give the container an alias, and you can manage the container through this alias in the future
-p 3307: 3307 maps the 3307 port of the host to the 3306 port of the Mysql container
- e MySQL container environment configuration
MYSQL_ROOT_PASSWORD=123456 Specify the password for mysql. The user name defaults to root. Note that if the password is not specified, the startup will fail.
4. View The mysql container we have started
docker ps
5. Enter the docker exec command used in the MySQL container
docker exec -it mysql bash
, -it is the parameter, bash means Create an interactive interface
For more related tutorials, please pay attention to thedocker tutorialcolumn on the PHP Chinese website.
The above is the detailed content of How to run mysql on docker. For more information, please follow other related articles on the PHP Chinese website!