The use of the MySQL official Docker image

Source: Internet
Author: User
Tags docker run

Reprint: http://www.cnblogs.com/cfrost/p/6241892.html

The first is pull image, and here I take5.6.35:

1 sudodocker pull mysql:5.6.35

After pulling down the big can follow the official instructions no brain start, but external inaccessible, so bound port:

1 sudodocker run --name mysql -p 12345:3306 -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:5.6.35

Try to connect with the client, success, query Mysql.user table found to allow access from anywhere with root, this is too insecure!

Decisively connect to bash:

1 sudodocker exec-it mysql bash

Run MySQL, even have!

Here is the basic operation, recover root permissions, build the library, open the user ...

Wait, where's the database file? Also, the character set is not UTF-8?? Read the official documentation and learn/etc/mysql/conf.d下可以自定义配置文件,于是乎自己建了一个my.cnf,重新运行:

1 sudodocker run --name mysql -p 12345:3306 -v $DOCKER_RUNTIME/mysql/data:/var/lib/mysql -v$DOCKER_RUNTIME/mysql/conf:/etc/mysql/conf.d -d mysql:5.6.35

By the way, the database file directory is changed, $DOCKER _runtime is my own definition of environment variables, you can specify.

ok~

The use of the MySQL official Docker image

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.