Docker is the latest hot technology, the technology industry is a network of red. In the nature of the technical people toss, try to change the local MySQL server to use Docker execution, this article records toss process, to make a memo.
The steps are as follows:
1: Install Docker
Find your own documents.
2: Using the official Docker image of MySQL, the command is as follows
Docker Pull mysql/mysql-server:5.7.16 # # (This is the latest stable version of MySQL when this article is published, and it's best to be consistent with the local version of MySQL, otherwise the third step may be problematic.) )
Because of the GFW, the process is a little long. After the execution of the command, the execution of the word "Docker images" shows that the Mysql-server is successful.
3: Run Docker images, have a few attention points
A: Port number problem, by default 3306 is occupied, so use other ports for mapping, such as 6603
B: Data file mapping problem can be viewed by performing "Ps-ef|grep MySQL". View the section of the--datadir option. As an example of MySQL installed under Mac, the result is
--datadir=/usr/local/var/mysql
After confirming the above question, execute the following command:
Docker run--name my-mysql-server-p 6604:3306-d-v/usr/local/var/mysql:/var/lib/mysql mysql/mysql-server:5.7.16
Then execute "Docker ps-a" to see if the container that is known as My-mysql-server is running. If so, congratulations, you should be successful.
4: The management of MySQL, there are two ways:
A: Enter the MySQL docker environment for execution. Execute the command as follows, and other operations are the same as normal management.
Docker exec-it My-mysql-server Bash
B: External use of MYSQL commands or other MySQL client software links. Need attention, host name part, if use localhost, try 127.0.0.1 general can. If you still have a problem, you will need to reconfigure the permissions table.
The above is a small set to introduce the MAC will brew installed MySQL to use Docker to perform the operation process, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!