@@ -174,19 +174,9 @@ docker_init_client_command() {
174174 mysql=( mysql --defaults-file=" ${PASSFILE} " --protocol=socket -uroot -hlocalhost --socket=" ${SOCKET} " )
175175}
176176
177- # Store root password in a file for use with the client command
178- mysql_write_password_file () {
179- # Write the password to the file the client uses
180- if [ ! -z " $MYSQL_ROOT_PASSWORD " ]; then
181- cat > " ${PASSFILE} " << EOF
182- [client]
183- password="${MYSQL_ROOT_PASSWORD} "
184- EOF
185- fi
186- }
187-
188- # Sets root password and creates root users for non-localhost hosts
189- docker_init_root_user () {
177+ # Creates initial database users and schema
178+ docker_setup_db () {
179+ # Sets root password and creates root users for non-localhost hosts
190180 rootCreate=
191181 # default root to listen for connections from anywhere
192182 if [ ! -z " $MYSQL_ROOT_HOST " -a " $MYSQL_ROOT_HOST " != ' localhost' ]; then
@@ -209,10 +199,16 @@ docker_init_root_user() {
209199 DROP DATABASE IF EXISTS test ;
210200 FLUSH PRIVILEGES ;
211201 EOSQL
212- }
213202
214- # Creates a custom database and user if specified
215- docker_setup_db_users () {
203+ # Write the password to the file the client uses
204+ if [ ! -z " $MYSQL_ROOT_PASSWORD " ]; then
205+ cat > " ${PASSFILE} " << EOF
206+ [client]
207+ password="${MYSQL_ROOT_PASSWORD} "
208+ EOF
209+ fi
210+
211+ # Creates a custom database and user if specified
216212 if [ " $MYSQL_DATABASE " ]; then
217213 mysql_note " Creating database ${MYSQL_DATABASE} "
218214 echo " CREATE DATABASE IF NOT EXISTS \` $MYSQL_DATABASE \` ;" | " ${mysql[@]} "
@@ -293,11 +289,7 @@ _main() {
293289 docker_generate_root_password
294290 fi
295291
296- docker_init_root_user
297-
298- mysql_write_password_file
299-
300- docker_setup_db_users
292+ docker_setup_db
301293
302294 echo
303295 for f in /docker-entrypoint-initdb.d/* ; do
0 commit comments