@@ -174,19 +174,9 @@ docker_init_client_command() {
174
174
mysql=( mysql --defaults-file=" ${PASSFILE} " --protocol=socket -uroot -hlocalhost --socket=" ${SOCKET} " )
175
175
}
176
176
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
190
180
rootCreate=
191
181
# default root to listen for connections from anywhere
192
182
if [ ! -z " $MYSQL_ROOT_HOST " -a " $MYSQL_ROOT_HOST " != ' localhost' ]; then
@@ -209,10 +199,16 @@ docker_init_root_user() {
209
199
DROP DATABASE IF EXISTS test ;
210
200
FLUSH PRIVILEGES ;
211
201
EOSQL
212
- }
213
202
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
216
212
if [ " $MYSQL_DATABASE " ]; then
217
213
mysql_note " Creating database ${MYSQL_DATABASE} "
218
214
echo " CREATE DATABASE IF NOT EXISTS \` $MYSQL_DATABASE \` ;" | " ${mysql[@]} "
@@ -293,11 +289,7 @@ _main() {
293
289
docker_generate_root_password
294
290
fi
295
291
296
- docker_init_root_user
297
-
298
- mysql_write_password_file
299
-
300
- docker_setup_db_users
292
+ docker_setup_db
301
293
302
294
echo
303
295
for f in /docker-entrypoint-initdb.d/* ; do
0 commit comments