Docker is a recent hot technology, and it is the Internet of the technical community. Based on the nature of the tech-savvy, I tried to change the local MySql server to docker for execution. This article records the tossing process for memo.
The procedure is as follows:
1: install docker
Find your own document
2: Use the docker image officially released by mysql. The command is as follows:
1
Docker pull mysql/mysql-server: 5.7.16 # (this is the latest stable MySql version released in this article, and it is best to be consistent with the local Mysql version, otherwise the third step may be faulty .)
Due to GFW, this process is a long one. After the command is executed, run "docker images". If mysql-server is displayed, the command is successful.
3: run docker images. Pay attention to the following points:
A: The port number is incorrect. By default, 3306 is occupied, so other ports are used for ING, such as 6603.
B: For data file ing problems, run "ps-ef | grep mysql. View the -- datadir option section. Take mysql installed in brew on mac as an example. The result is:
1
-- Datadir =/usr/local/var/mysql
After confirming the problem, run the following command:
1
Docker run -- name my-mysql-server-p 6604: 3306-d-v/usr/local/var/mysql:/var/lib/mysql-server: 5.7.16
Run "docker ps-a" to check whether the container named my-mysql-server is running. If so, congratulations, you should have succeeded.
4: There are two ways to manage mysql:
A: Enter the mysql docker environment for execution. Run the following command to perform other operations.
1
Docker exec-it my-mysql-server bash
B: use mysql commands or other mysql client software links externally. Note that for the host name, if localhost is not used, try 127.0.0.1. If the problem persists, you need to reconfigure the permission table.