Use Docker to install MySQL under "Docker" Centos7

Source: Internet
Author: User
Tags docker run

1 getting the MySQL image

Docker pull  MySQL:5.7

2 Create a MySQL image and run

3307:3306 -E [email protected]666 --name codeforphp_mysql mysql:5.7

Parameter description
-D Let the container run in the background
-P adding host-to-container port mappings
-e Set the environment variable, here is the initial password to set the root user of MySQL, this must be set
–name the name of the container, whatever it takes, but must be unique

PS: Actually we can just use the Docker Run command. The Docker run will first pull and then create. Personal habits pull the mirror down first, and it will be fast in run.

3 Entering MySQL terminal

Docker exec-it   codeforphp_mysql    Bash

Parameter description
-T produces a pseudo terminal in a container
-I interacts with standard input (STDIN) within the container

Enter the command. Enter

[Email protected]:/# mysql-uroot-Penter Password:welcome to the MySQL Monitor. Commands End With; or \g.your MySQL connection ID is 3Server Version:5.7. AMySQL Community Server (GPL) Copyright (c) -,2018, Oracle and/or its affiliates. All rights reserved. Oracle isA registered trademark of Oracle Corporation and/or Itsaffiliates. Other names trademarks of their respectiveowners. Type'Help ;'Or'\h'  forHelp. Type'\c'To clear the current input statement.mysql>

After entering, authorize the user to use the remote connection

GRANT all privileges on * * to'Root'@'localhost'Identified by'[email protected]'; GRANT all Privileges on*. * To'Root'@'%'Identified by'[email protected]'; GRANT all Privileges on*. * To'Root'@'127.0.0.1'Identified by'[email protected]';
FLUSH privileges;

At this point you can use the client connection to see. Note that the client connection port is 3307

Use Docker to install MySQL under

Docker centos7

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.