How to execute MySQL command from the host to container running MySQL server?

前端 未结 9 1818
春和景丽
春和景丽 2021-01-30 06:31

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 run

9条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-30 07:15

    For @Abdullah Jibaly solution, after tested in MySQL 5.7, it would only entered into bash terminal prompt, whereby you still need to enter mysql command second time.

    In order to directly enter into MySQL command line client after run MySQL container with one line of command, just run the following:

    docker exec -it container_mysql_name mysql -u username -p
    

提交回复
热议问题