Skip to content

Commit b297b6e

Browse files
committed
Bug #86523 Wrong root user altered for MYSQL_ONETIME_PASSWORD
If the variable is set, the entrypoint script will expire the root user, but the code wasn't updated after the default root user was changed from @% to @localhost (+ optional @MYSQL_ROOT_HOST), so the statement fails.
1 parent 674778b commit b297b6e

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed

5.6/docker-entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,16 @@ if [ "$1" = 'mysqld' ]; then
107107
done
108108

109109
if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
110-
"${mysql[@]}" <<-EOSQL
111-
ALTER USER 'root'@'%' PASSWORD EXPIRE;
112-
EOSQL
110+
if [ ! -z "$MYSQL_ROOT_HOST" ]; then
111+
"${mysql[@]}" <<-EOSQL
112+
ALTER USER 'root'@'${MYSQL_ROOT_HOST}' PASSWORD EXPIRE;
113+
ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
114+
EOSQL
115+
else
116+
"${mysql[@]}" <<-EOSQL
117+
ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
118+
EOSQL
119+
fi
113120
fi
114121
if ! kill -s TERM "$pid" || ! wait "$pid"; then
115122
echo >&2 'MySQL init process failed.'

5.7/docker-entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,16 @@ if [ "$1" = 'mysqld' ]; then
105105
done
106106

107107
if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
108-
"${mysql[@]}" <<-EOSQL
109-
ALTER USER 'root'@'%' PASSWORD EXPIRE;
110-
EOSQL
108+
if [ ! -z "$MYSQL_ROOT_HOST" ]; then
109+
"${mysql[@]}" <<-EOSQL
110+
ALTER USER 'root'@'${MYSQL_ROOT_HOST}' PASSWORD EXPIRE;
111+
ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
112+
EOSQL
113+
else
114+
"${mysql[@]}" <<-EOSQL
115+
ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
116+
EOSQL
117+
fi
111118
fi
112119
if ! kill -s TERM "$pid" || ! wait "$pid"; then
113120
echo >&2 'MySQL init process failed.'

8.0/docker-entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,16 @@ if [ "$1" = 'mysqld' ]; then
105105
done
106106

107107
if [ ! -z "$MYSQL_ONETIME_PASSWORD" ]; then
108-
"${mysql[@]}" <<-EOSQL
109-
ALTER USER 'root'@'%' PASSWORD EXPIRE;
110-
EOSQL
108+
if [ ! -z "$MYSQL_ROOT_HOST" ]; then
109+
"${mysql[@]}" <<-EOSQL
110+
ALTER USER 'root'@'${MYSQL_ROOT_HOST}' PASSWORD EXPIRE;
111+
ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
112+
EOSQL
113+
else
114+
"${mysql[@]}" <<-EOSQL
115+
ALTER USER 'root'@'localhost' PASSWORD EXPIRE;
116+
EOSQL
117+
fi
111118
fi
112119
if ! kill -s TERM "$pid" || ! wait "$pid"; then
113120
echo >&2 'MySQL init process failed.'

0 commit comments

Comments
 (0)