如何从主机到运行MySQL服务器的容器执行MySQL命令? [英] How to execute MySQL command from the host to container running MySQL server?
问题描述
我已按照 https://registry.hub.docker.com/中的说明进行操作_/mysql/提取图像并运行一个容器,在该容器中运行MySQL服务器.
I have followed the instruction in https://registry.hub.docker.com/_/mysql/ to pull an image and running a container in which it runs a MySQL server.
容器正在后台运行,我想运行一些命令.
The container is running in the background and I would like to run some commands.
哪种方法是连接到容器并从命令行执行此命令的最佳方法?
Which is the best way to connect to the container and execute this command from command line?
谢谢.
推荐答案
您可以使用以下方法连接到mysql容器并运行命令:
You can connect to your mysql container and run your commands using:
docker exec -it mysql bash -l
(其中 mysql
是您为容器指定的名称)
(Where mysql
is the name you gave the container)
请记住,您所做的任何事情都不会持续到下一次从同一映像运行容器时.
Keep in mind that anything you do will not persist to the next time your run a container from the same image.
这篇关于如何从主机到运行MySQL服务器的容器执行MySQL命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!