Skip to content

Commit 547ba49

Browse files
committed
added option to allow skipping DB user create
1 parent 736774d commit 547ba49

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

newMysql.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ FORCE_REDO=0
2727
# if set, SQL queries & output printed
2828
SQL_DEBUG=0
2929

30+
# if set, recreate user accounts unless access to db already ok (existing ones will be deleted, including their privileges)
31+
SQL_RECREATE_USER=1
32+
3033
# where are we running now
3134
HERE=`hostname -f`
3235

@@ -240,9 +243,11 @@ for CONFIG in "${EXTRA_CONFIG[@]}"; do
240243
fi
241244

242245
for QHOST in "%" "localhost" "${HERE}"; do
243-
mysqlExecute "drop user \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\";"
244-
mysqlExecute "create user \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\";"
245-
mysqlExecute "set password for \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\" = PASSWORD(\"${EXTRA_PWD[$CONFIG]}\");"
246+
if [ "$SQL_RECREATE_USER" == "1" ]; then
247+
mysqlExecute "drop user \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\";"
248+
mysqlExecute "create user \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\";"
249+
mysqlExecute "set password for \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\" = PASSWORD(\"${EXTRA_PWD[$CONFIG]}\");"
250+
fi
246251
mysqlExecute "grant ${EXTRA_PRIVILEGE[$CONFIG]} on $INFOLOGGER_DB_NAME.* to \"${EXTRA_USER[$CONFIG]}\"@\"${QHOST}\";"
247252
done
248253
done

0 commit comments

Comments
 (0)