Use Docker to run MySql installed in brew on Mac.

Source: Internet
Author: User
Tags mysql client mysql commands mysql version port number docker ps docker run

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.