Build MySQL Database under Docker

Source: Internet
Author: User
Tags docker ps docker run

1. get the official image:

[email protected] mysql]# Docker pull mysql/mysql-server:latestlatest:pulling from MYSQL/MYSQL-SERVER1F5B026B07BC: Pull complete 3d5697fc1304:pull Complete 2747c84403db:pull complete Dc0c445a852b:pull complete digest:sha256:7aba8c77f 9e9d24b209348c46a6496a4c9090cd27798963f8bc14d64fab67006status:downloaded newer image for Mysql/mysql-server:latest

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M01/97/45/wKiom1ksF6_A-jzyAADB9_chrXg790.jpg-wh_500x0-wm_ 3-wmp_4-s_415984519.jpg "title=" 2017-05-29_201719.jpg "alt=" wkiom1ksf6_a-jzyaadb9_chrxg790.jpg-wh_50 "/>

2. View the image

Docker images

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M01/97/46/wKioL1ksF8jTa17pAABowfoILII039.jpg-wh_500x0-wm_ 3-wmp_4-s_412041365.jpg "title=" 2017-05-29_201825.jpg "alt=" wkiol1ksf8jta17paabowfoilii039.jpg-wh_50 "/>

3. Create a MySQL container

Docker run--name mysql-p 3306:3306-e mysql_root_password=fanshine-d mysql/mysql-server:latest

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M01/97/46/wKioL1ksF93htBmWAABia3t7s_I448.jpg-wh_500x0-wm_ 3-wmp_4-s_1923928673.jpg "title=" 2017-05-29_202634.jpg "alt=" wkiol1ksf93htbmwaabia3t7s_i448.jpg-wh_50 "/>

4. View all the containers created

Docker Ps-a

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M02/97/45/wKiom1ksF_Kha4HSAACxMyktR0Q862.jpg-wh_500x0-wm_ 3-wmp_4-s_602111771.jpg "title=" 2017-05-29_202845.jpg "alt=" wkiom1ksf_kha4hsaacxmyktr0q862.jpg-wh_50 "/>

5. View the running MySQL container

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M02/97/46/wKioL1ksGAbwuDNRAABrojE1L4M485.jpg-wh_500x0-wm_ 3-wmp_4-s_1306224573.jpg "title=" 2017-05-29_202946.jpg "alt=" Wkiol1ksgabwudnraabroje1l4m485.jpg-wh_50 "/>

6. You can start, stop, and restart the MySQL container in the following command format

Docker [Start | stop | restart] "ID"

more commands can be obtained by Docker--help View

7. Test, connect MySQL database

1) Enter Bash mode:

Docker exec-it 852cd6ae2236 Bash

650) this.width=650; "Src=" https://s3.51cto.com/wyfs02/M02/97/45/wKiom1ksGCSjxkFmAAA3mcPk6kU095.jpg-wh_500x0-wm_ 3-wmp_4-s_312302781.jpg "title=" 2017-05-29_203621.jpg "alt=" wkiom1ksgcsjxkfmaaa3mcpk6ku095.jpg-wh_50 "/>

2) Enter the MySQL password to connect to the database:

Mysql-uroot-p

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M02/97/46/wKioL1ksGDbw6lTVAADIN8qssiY735.jpg-wh_500x0-wm_ 3-wmp_4-s_703943655.jpg "title=" 2017-05-29_203718.jpg "alt=" wkiol1ksgdbw6ltvaadin8qssiy735.jpg-wh_50 "/>  


Build MySQL Database under Docker

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.