Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install mysql docker Image

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to install the mysql docker image, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Install mysql docker image search image NAME DESCRIPTION STARS OFFICIAL AUTOMATEDmysql MySQL is a widely used, open-source relation... 8448 [OK] mariadb MariaDB is a community-developed fork of MyS... 2907 [OK] pull image docker pull mysql:tag

Mirror version of tag mysql

Start the mysql image docker run\-- name dmysql\-- p 3307 name dmysql 3306\-e MYSQL_ROOT_PASSWORD=root\-dmysql: 5.7\-- character-set-server=utf8mb4\-- collation-server=utf8mb4_unicode_ci

-- name of the name mysql startup service

-p map the mirrored [3306] port to the host's port [3307]

-e set the environment variable of the image

The variable MYSQL_ROOT_PASSWORD is mandatory and the specified password will be set to the MySQL root root user account. In the above example, it is set to root.

The variable MYSQL_DATABASE is optional and allows you to create an image boot on the database with the specified name. If a user / password is provided (see below), the user will get superuser access (GRANT) corresponding to the database.

MYSQL_USER MYSQL_PASSWORD these variables are optional and are used to create a new user and set the user's password. This user will be given superuser privileges (see figure above) to specify the MYSQL_DATABASE variable for the database. Both variables need to create a user.

[note]: there is no need to use this mechanism to create the root superuser, who creates the variable specified by the default password MYSQL_ROOT_PASSWORD.

MYSQL_ALLOW_EMPTY_PASSWORD this is an optional variable. Set to yes allows the container to start a blank root user's password.

[note]: this variable is not recommended to be set to yes unless you really know what you are doing, as this will leave your MySQL instance completely unguarded and allow anyone to get full superuser access.

MYSQL_RANDOM_ROOT_PASSWORD this is an optional variable. Set to yes to generate a random initial password for the root user (using pwgen). The generated root password will be printed to stdout (GENERATED ROOT PASSWORD:.).

MYSQL_ONETIME_PASSWORD setting root (not user-specified MYSQL_USER!) After the user expiration initialization is complete, force the login password to change for the first time. Note: this feature only supports MySQL 5.6 +. Using this option to properly MySQL 5.5 during initialization will throw an error.

Check out the Mysql process $docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES1094bc7f4078 mysql:5.7 "docker-entrypoint.s …" 2 months ago Up 3 hours 33060/tcp, 0.0.0.0 shell 3307-> 3306/tcp dmysql container access and view MySQL logs

The docker exec command allows you to run commands into a docker container. The following command line can enter the bash shell interface of the mysql container:

-Linux$ docker exec-it mysql-uroot-Pmuri-Windows$ docker exec-it 1094bc7f4078 / bin/bashthe input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty' changed to: $winpty docker exec-it 1094bc7f4078 mysql-uroot-pEnter password:Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 83Server version: 5.7.26 MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql >

View the container log through the log parameter:

Docker logs views the list of all parameters of mysql image $docker run-it-- rm mysql:-- verbose-- help

Add winpty under windows

Thank you for reading this article carefully. I hope the article "how to install mysql docker Image" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report