From 2ea828ad54d8b58ab8f5774d26b3b104980bee38 Mon Sep 17 00:00:00 2001 From: flytreeleft Date: Sun, 10 Mar 2019 10:38:46 +0800 Subject: [PATCH 1/3] Add 'FLUSH PRIVILEGES;' to avoid creating 'root'@'${MYSQL_ROOT_HOST}' to be failed when MYSQL_ROOT_HOST isn't '%' --- 5.5/docker-entrypoint.sh | 1 + 5.6/docker-entrypoint.sh | 1 + 5.7/docker-entrypoint.sh | 1 + 8.0/docker-entrypoint.sh | 1 + 4 files changed, 4 insertions(+) diff --git a/5.5/docker-entrypoint.sh b/5.5/docker-entrypoint.sh index cd1855f3f..647619cfd 100755 --- a/5.5/docker-entrypoint.sh +++ b/5.5/docker-entrypoint.sh @@ -158,6 +158,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then DELETE FROM mysql.user WHERE user NOT IN ('mysql.sys', 'mysqlxsys', 'root') OR host NOT IN ('localhost') ; SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ; + FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; FLUSH PRIVILEGES ; diff --git a/5.6/docker-entrypoint.sh b/5.6/docker-entrypoint.sh index 7dbd6975a..46ebdbc00 100755 --- a/5.6/docker-entrypoint.sh +++ b/5.6/docker-entrypoint.sh @@ -158,6 +158,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then DELETE FROM mysql.user WHERE user NOT IN ('mysql.sys', 'mysqlxsys', 'root') OR host NOT IN ('localhost') ; SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ; + FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; FLUSH PRIVILEGES ; diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index b38c11287..fe7a8cf9a 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -163,6 +163,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ; + FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; FLUSH PRIVILEGES ; diff --git a/8.0/docker-entrypoint.sh b/8.0/docker-entrypoint.sh index 720ef6d65..17248882d 100755 --- a/8.0/docker-entrypoint.sh +++ b/8.0/docker-entrypoint.sh @@ -165,6 +165,7 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ; + FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; FLUSH PRIVILEGES ; From a411161b9941a8eac1a9cde278b8f1e1df1197d9 Mon Sep 17 00:00:00 2001 From: flytreeleft Date: Wed, 13 Mar 2019 22:45:13 +0800 Subject: [PATCH 2/3] 'FLUSH PRIVILEGES;' is unnecessary for MySQL 5.7+ after creating the 'root'@'localhost'. --- 5.7/docker-entrypoint.sh | 1 - 8.0/docker-entrypoint.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/5.7/docker-entrypoint.sh b/5.7/docker-entrypoint.sh index fe7a8cf9a..b38c11287 100755 --- a/5.7/docker-entrypoint.sh +++ b/5.7/docker-entrypoint.sh @@ -163,7 +163,6 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then SET PASSWORD FOR 'root'@'localhost'=PASSWORD('${MYSQL_ROOT_PASSWORD}') ; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ; - FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; FLUSH PRIVILEGES ; diff --git a/8.0/docker-entrypoint.sh b/8.0/docker-entrypoint.sh index 17248882d..720ef6d65 100755 --- a/8.0/docker-entrypoint.sh +++ b/8.0/docker-entrypoint.sh @@ -165,7 +165,6 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ; GRANT ALL ON *.* TO 'root'@'localhost' WITH GRANT OPTION ; - FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; FLUSH PRIVILEGES ; From 36a3e7be69538e4c2dec68372ebc4edeabcc7d12 Mon Sep 17 00:00:00 2001 From: flytreeleft Date: Thu, 14 Mar 2019 23:04:50 +0800 Subject: [PATCH 3/3] Remove the redundant 'FLUSH PRIVILEGES', only 'DELETE FROM' or 'DROP USER' needs a FLUSH. --- 5.5/docker-entrypoint.sh | 1 - 5.6/docker-entrypoint.sh | 1 - 2 files changed, 2 deletions(-) diff --git a/5.5/docker-entrypoint.sh b/5.5/docker-entrypoint.sh index 647619cfd..6e8db71f3 100755 --- a/5.5/docker-entrypoint.sh +++ b/5.5/docker-entrypoint.sh @@ -161,7 +161,6 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; - FLUSH PRIVILEGES ; EOSQL if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then diff --git a/5.6/docker-entrypoint.sh b/5.6/docker-entrypoint.sh index 46ebdbc00..4302dde7b 100755 --- a/5.6/docker-entrypoint.sh +++ b/5.6/docker-entrypoint.sh @@ -161,7 +161,6 @@ if [ "$1" = 'mysqld' -a -z "$wantHelp" ]; then FLUSH PRIVILEGES ; ${rootCreate} DROP DATABASE IF EXISTS test ; - FLUSH PRIVILEGES ; EOSQL if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then