Skip to content

Commit

Permalink
Move flag for password file to when the client command is first defined
Browse files Browse the repository at this point in the history
All options regarding config files must be the first specified, so adding
it later doesn't work.
Using --defaults-file instead of --defaults-extra-file should also mounted
config files from interfering with the connection
  • Loading branch information
ltangvald authored and yosifkit committed Sep 18, 2019
1 parent 03bdbad commit 2242976
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .template.Debian/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
fi

SOCKET="$(_get_config 'socket' "$@")"
mysql=( mysql --no-defaults --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )
# We create a file to store the root password in so we don''t use it on the command line
install -d -m0700 /tmp/mysql-files
PASSFILE=$(mktemp /tmp/mysql-files/XXXXXXXXXX)
install /dev/null -m0600 "${PASSFILE}"

mysql=( mysql --defaults-file="${PASSFILE}" --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )
_note "Starting server"
_start_server "${SOCKET}" "$@"
if [ "${MYSQL_MAJOR}" = "5.5" ] || [ "${MYSQL_MAJOR}" = "5.6" ]; then
Expand Down Expand Up @@ -200,16 +205,12 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
FLUSH PRIVILEGES ;
EOSQL

# Store the password in a file so we don't use it on the command line
install -d -m0700 /tmp/mysql-files
PASSFILE=$(mktemp /tmp/mysql-files/XXXXXXXXXX)
install /dev/null -m0600 "${PASSFILE}"
# Write the password to the file the client uses
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
cat >"${PASSFILE}" <<EOF
[client]
password="${MYSQL_ROOT_PASSWORD}"
EOF
mysql+=( --defaults-extra-file="${PASSFILE}" )
fi

file_env 'MYSQL_DATABASE'
Expand Down

0 comments on commit 2242976

Please sign in to comment.