Closed s-tanishima closed 12 months ago
Where does "${mysql[@]}"
coming from? I'm not finding anything on it
Piping to just mysql
worked for me
echo "CREATE DATABASE IF NOT EXISTS sample_schema ;" | mysql --user=root
Maybe "${mysql[@]}"
was a shortcut created in another script? You can recreate in in your entrypoint by doing something like
export mysql=('mysql' '--user=root')
echo "CREATE DATABASE IF NOT EXISTS sample_schema ;" | "${mysql[@]}"
Thank you for reply.
I also looked into it.
The /entrypoint.sh
file inside the container has the following description on MySQL Server 8.0.18-1debian9
.
process_init_file() {
local f="$1"; shift
local mysql=( "$@" )
case "$f" in
*.sh) echo "$0: running $f"; . "$f" ;;
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
*) echo "$0: ignoring $f" ;;
esac
echo
}
I used "${mysql[@]}"
according to this description, and it was actually working.
Anyway, I understand from your reply that "${mysql[@]}"
is not common.
Can we close the issue?
Yes, I will close it.
thank you for your reply.
I don't know the cause.
OS
Ubuntu 22.04.2 LTS on WSL2 (But it worked fine on Amazon Linux2)
Overview
"${mysql[@]}"
is empty in shellscript. ex)echo "CREATE DATABASE IF NOT EXISTS sample_schema ;" | "${mysql[@]}"
in docker-compose.yml
image: mysql:8.0
run Image
MySQL Server 8.0.34-1.el8
docker compose logs image
[Note] [Entrypoint]: /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/sample.sh
Avoidance
add build version in docker-compose.yml
image: mysql:8.0.18
run Image
MySQL Server 8.0.18-1debian9
it worked fine on Ubuntu 22.04.2 LTS.