docker-library / mysql

Docker Official Image packaging for MySQL Community Server
https://dev.mysql.com/
GNU General Public License v2.0
2.46k stars 2.19k forks source link

Processes executed by shellscripts no longer work in mysql server 8.0.19 and later. #999

Closed s-tanishima closed 12 months ago

s-tanishima commented 12 months ago

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.

LaurentGoderre commented 12 months ago

Where does "${mysql[@]}" coming from? I'm not finding anything on it

LaurentGoderre commented 12 months ago

Piping to just mysql worked for me

echo "CREATE DATABASE IF NOT EXISTS sample_schema ;" | mysql --user=root
LaurentGoderre commented 12 months ago

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[@]}"
s-tanishima commented 12 months ago

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.

s-tanishima commented 12 months ago

Anyway, I understand from your reply that "${mysql[@]}" is not common.

LaurentGoderre commented 12 months ago

Can we close the issue?

s-tanishima commented 12 months ago

Yes, I will close it.

thank you for your reply.