1. Find the mysql mirrors on Docker Hub
sudo docker search mysql
2. Pull the official image
sudo docker pull mysql
3. Check the image information
sudo docker images
4. Use of the container run mysql mirror
sudo docker run --name mysqldb -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:latest
5. Check the vessel to start
sudo docker ps
6.docker mysql installation has been completed
Here is the MySQL open container of execution called mysqldb
sudo docker start mysqldb
sudo docker exec -it mysqldb /bin/bash
7. Close the container mysqldb
sudo docker stop mysqldb
8. command to connect
mysql -u root -p
9. Exit
exit
note:
After installation is complete docker command not found at this time do not worry
first Linux server can be used to reopen closed up
then you will find mysql -u root -p command mysql connection will be a mistake
to say that the file can not be found
Input:
mysql -u root -h 127.0.0.1 -p
Specify what address, so that you can go up connection
if you add -h127.0.0.1 you can log database, indicating that the database is running.
Find mysql.sock by the find command file, find the file does not exist, and my understanding is that mysql generated files when failed, this is not the focus of our research