I have a shell script and want to invoke via command line the mysql client
cat \
"${SQL_DIR}/mysql-schema.sql" \
"${SQL_DIR}/privileges.sql" \
"${SQL_DIR}/mysql-import.sql" \
"${SQL_DIR}/after.sql" \
| docker exec -i "${PREPARE_NAME}" mysql -h127.0.0.1 -P 3306 -uroot -proot --default-character-set=utf8
it tells me
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
read unix @->/var/run/docker.sock: read: connection reset by peer
If I do this from the command line everything works fine.
What shall I do?
docker exec "${PREPARE_NAME}" mysql -h127.0.0.1 -P 3306 -uroot -proot --default-character-set=utf8by itself connect to mysql? Does the script fail immediately or after a while?SQL_DIRandPREPARE_NAME? What is the host OS? What version Docker (docker version)? What is the current folder (pwd)?$SQL_DIRand$PREPARE_NAMEare just variables in the script and are not necessary for reproducing the problem.cat ... | docker exec -i container-name mysql -h127.0.0.1 -uroot -prootdoesn't work within a bash script. The container has a mysql client.