Skip to content

Commit 56e8685

Browse files
committed
Use MySQL root user password if set, otherwise it fails to connect
1 parent bbbfd87 commit 56e8685

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

resources/rondb_scripts/mysql-client.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,20 @@ fi
2525

2626
MYSQL_SOCKET=$(/srv/hops/mysql-cluster/ndb/scripts/get-mysql-socket.sh)
2727
echo "Using socket: $MYSQL_SOCKET"
28+
29+
password_arg="-p\$MYSQL_ROOT_PASSWORD"
30+
if [ -z $MYSQL_ROOT_PASSWORD ]; then
31+
password_arg="--skip-password"
32+
fi
33+
2834
if [ "$EXECUTE_SQL" = "-e" ]; then
29-
mysql_command='/srv/hops/mysql/bin/mysql --defaults-file=$MYSQL_CONF -u root --skip-password -S $MYSQL_SOCKET $DB $EXECUTE_SQL "$@"'
35+
mysql_command='/srv/hops/mysql/bin/mysql --defaults-file=$MYSQL_CONF -u root $password_arg -S $MYSQL_SOCKET $DB $EXECUTE_SQL "$@"'
3036
# Don't echo code in production because other programs rely on reading the script's output
3137
# echo "Executing command: $mysql_command"
3238
eval $mysql_command
3339
else
3440
# Case 3
35-
mysql_command="/srv/hops/mysql/bin/mysql --defaults-file=$MYSQL_CONF -u root --skip-password -S $MYSQL_SOCKET $DB $@"
41+
mysql_command="/srv/hops/mysql/bin/mysql --defaults-file=$MYSQL_CONF -u root $password_arg -S $MYSQL_SOCKET $DB $@"
3642
# Don't echo code in production because other programs rely on reading the script's output
3743
# echo "Executing command: $mysql_command"
3844
eval $mysql_command

0 commit comments

Comments
 (0)