Skip to content

Commit 2242976

Browse files
ltangvaldyosifkit
authored andcommitted
Move flag for password file to when the client command is first defined
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
1 parent 03bdbad commit 2242976

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

.template.Debian/docker-entrypoint.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
156156
fi
157157

158158
SOCKET="$(_get_config 'socket' "$@")"
159-
mysql=( mysql --no-defaults --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )
159+
# We create a file to store the root password in so we don''t use it on the command line
160+
install -d -m0700 /tmp/mysql-files
161+
PASSFILE=$(mktemp /tmp/mysql-files/XXXXXXXXXX)
162+
install /dev/null -m0600 "${PASSFILE}"
163+
164+
mysql=( mysql --defaults-file="${PASSFILE}" --protocol=socket -uroot -hlocalhost --socket="${SOCKET}" )
160165
_note "Starting server"
161166
_start_server "${SOCKET}" "$@"
162167
if [ "${MYSQL_MAJOR}" = "5.5" ] || [ "${MYSQL_MAJOR}" = "5.6" ]; then
@@ -200,16 +205,12 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then
200205
FLUSH PRIVILEGES ;
201206
EOSQL
202207

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

215216
file_env 'MYSQL_DATABASE'

0 commit comments

Comments
 (0)