Docker mounts MySQL with volume mode Docker-compose login not in

Source: Internet
Author: User

Information:
    • Docker version ( $ docker --version ): Docker version 18.03.1-ce, version 9ee9f40
    • System Information: WINDOWS10 Professional Edition

MySQL is mounted in Docker's volume

1. The first step:

1 Docker volume create Mysql-data

2. Step Two:

Create a MySQL folder

3. Step Three:

Re-create docker-compose.yml under MySQL folder

Because the latest version of Docker does not support the absolute path representation of/g/, the relative path to./is "relative to Docker-compose.yml")

1Version'3'2 Services:3 DB:4image:mysql/mysql-Server5container_name:db-MySQL6 restart:always7Command:mysqld--character-Set-server=utf8--collation-server=Utf8_general_ci8 Ports:9-"3306:3306"  Ten Networks: One-net_db A Environment: - mysql_root_password:pwd123456 - volumes: the-mysql-data:/var/lib/MySQL - volumes: -mysql-Data: -Externaltrue + Networks: - net_db: +Externaltrue

4. Step Fourth:

Docker-compose up

5. Step Fifth:

Login: 1 Docker exec-it db-MySQL bash 2 3 mysql-uroot-p 4 pwd12 3456

If it appears

 for ' Root '@'localhost' (using password:yes)

Please continue to see:

To delete a mirror:

List all images:
Docker images
Docker RMI   IMAGE ID

Delete Volume

1  List all Volume:
2 docker volume ls

Docker Volume RM Mysql-data

Delete MySQL folder

Repeat the above operation and add the DB to the IV command.

1 docker-compose up db

1C:\users\gyw>docker exec-it db-MySQL bash2bash-4.2# Mysql-uroot-P3 Enter Password:4 Welcome to the MySQL Monitor. Commands End With; or \g.5Your MySQL Connection ID is  -6Server version:8.0. OneMySQL Community Server-GPL7 8Copyright (c) -,2018, Oracle and/or its affiliates. All rights reserved.9 TenOracle isA registered trademark of Oracle Corporation and/or its One affiliates. Other names trademarks of their respective A owners. -  -Type'Help ;'Or'\h'  forHelp. Type'\c'To clear the current input statement. the  -Mysql>

Done!!!

Docker mounts MySQL with volume mode Docker-compose login not in

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.