I'm trying to automate these steps that I'm doing manually:
# Go into the container
docker exec -it mysql-container sh
# Log into MySQL
mysql -u root -ptest
# Specify the database
USE mydatabase;
# Call procedure_1
CALL procedure_1();
# Call procedure_2
CALL procedure_2();
My first approach was:
docker exec mysql-container mysql -u root -ptest -e "USE mydatabase; CALL procedure_1(); CALL procedure_2();"
I got an error that said procedure_1 doesn't exist. I looked around and found this answer so I updated my script to:
docker exec mysql-container mysql -u root -ptest -e "DELIMITER # USE mydatabase# BEGIN CALL procedure_1(); CALL procedure_2(); END# DELIMITER ;"
However this didn't seem to run at all, I didn't get any feedback. How do I call multiple MySQL stored procedures using docker exec?
mysql -h 127.0.0.1 mydatabaseon the host, without using thedocker execdebugging tool?3307:3306.DELIMITERon the command-line, because it always interprets the rest of the current line as the delimiter string. Also you can't useBEGINin MySQL except inside the body of stored routines.