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 use MySQL in Docker

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article is to share with you about how to use MySQL in Docker. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Download the image:

# docker pull mysql

Create a MySQL instance:

# docker run-p 3306 MYSQL_ROOT_PASSWORD=123456 3306-- name mysql-e MYSQL_ROOT_PASSWORD=123456-d chag/mysql

Connect to the MySQL:

# docker run-it-- link mysql:mysql-- rm mysql sh-c 'exec mysql-h "$MYSQL_PORT_3306_TCP_ADDR"-P "$MYSQL_PORT_3306_TCP_PORT"-uroot-p "$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

You can also go directly to the container and connect to MySQL.

# docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 944ba58d59dd chag/mysql:latest "/ entrypoint.sh mysq 7 days ago Up 7 hours 0.0.0.0 days ago Up 3306-> 3306/tcp mysql

Use the docker-enter command

# docker-enter mysqlroot@944ba58d59dd:~# mysql-uroot-p123456

You can enter mysql:

Warning: Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 1Server version: 5.6.25 MySQL Community Server (GPL) Copyright (c) 2000, 2015, 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 > show databases +-+ | Database | +-+ | information_schema | | mysql | | orcl | | performance_schema | +-+ 4 rows in set (0.16 sec) above is how to use MySQL in Docker The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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

Servers

Wechat

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

12
Report