Using Docker Mysql 5.7

Source: Internet
Author: User
Tags docker ps docker run

MySQL has already provided Docker image, which makes it easy to open a MySQL server. There are two ways to connect the official

    • Access the MySQL server container through--link in other app Docker containers
    • Start another MySQL container as a client, access the MySQL server container via--link

Both of these methods are in the container, and it is simple if the client does not access the Docker container:

1. Pull Mysql Image
$ docker Pull MySQL

The premise is that Docker has been installed, this can be referred to the Docker website, the steps are very detailed.

2. Create an external data mount point
$ sudo mkdir-p/var/docker_data/mysql/data$ sudo chmod 775-r/var/docker_data/msyql/

In addition to this approach, you can also choose to use Docker data volumes.

3. Start the MySQL container

With the-e parameter, you can set the parameters of the MySQL server, where the root password is set and a user dev with a password of Dev is created.

   $ docker run-p 3306:3306--name mysql-test-v/var/docker_data/mysql/data/:/var/lib/mysql-e mysql_root_password=root-e            Mysql_user=dev-e mysql_password=dev-d MYSQL #查看docker是否启动   $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a8ef529a9a1c  mysql "docker-entrypoint.sh" secon ds ago Up seconds 0.0.0.0:3306->3306/tcp Mysql-test

  

4. Link MySQL container in host
Use the IP address portion of the ports display as the-h parameter, and if it is not on the host, use the host's IP address.

  

Using Docker Mysql 5.7

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.