How to execute MySQL command from the host to container running MySQL server?
Solution 1:
You can connect to your mysql container and run your commands using:
docker exec -it mysql bash -l
(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.
Solution 2:
docker exec -i some_mysql_container mysql -uroot -ppassword <<< "select database();"