From 9ede46073bb82b4b5845a7dea6be416d69184bae Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 27 Nov 2020 02:23:47 -0700 Subject: [PATCH] use escaped backticks for table names --- entrypoint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 915a7e1..75d3356 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -41,7 +41,7 @@ if [ -z "$(ls -A /var/lib/mysql/ 2> /dev/null)" ]; then # statement to create new SQL database printf "DB-CREATE: Generating SQL database create statement for '%s'\n" "$MYSQL_DATABASE" - printf "CREATE DATABASE IF NOT EXISTS '%s' CHARACTER SET %s COLLATE %s;" "$MYSQL_DATABASE" "$MYSQL_CHARSET" "$MYSQL_COLLATION" >> "$sqlCmd" + printf "CREATE DATABASE IF NOT EXISTS \`%s\` CHARACTER SET %s COLLATE %s;" "$MYSQL_DATABASE" "$MYSQL_CHARSET" "$MYSQL_COLLATION" >> "$sqlCmd" # statements to: # cleanup permissions: @@ -55,7 +55,7 @@ if [ -z "$(ls -A /var/lib/mysql/ 2> /dev/null)" ]; then printf "GRANT ALL ON *.* TO 'root'@'%%' IDENTIFIED BY '%s' WITH GRANT OPTION;" "$MYSQL_ROOT_PASSWORD" >> "$sqlCmd" if [ -n "$MYSQL_USER" ] && [ -n "$MYSQL_PASSWORD" ]; then printf "DB-CREATE: Generating SQL permissions statement for '%s'\n" "$MYSQL_USER" - printf "GRANT ALL ON '%s.*' TO '%s'@'%%' IDENTIFIED BY '%s';" "$MYSQL_DATABASE" "$MYSQL_USER" "$MYSQL_PASSWORD" >> "$sqlCmd" + printf "GRANT ALL ON \`%s\`.* TO '%s'@'%%' IDENTIFIED BY '%s';" "$MYSQL_DATABASE" "$MYSQL_USER" "$MYSQL_PASSWORD" >> "$sqlCmd" fi printf "DB-CREATE: Generating statement to drop 'test' table\n" printf 'DROP DATABASE IF EXISTS test;' >> "$sqlCmd"