From 3bf937d2ea57e5bf54b80f508c868bc7e4ce0fce Mon Sep 17 00:00:00 2001 From: Yehonal Date: Mon, 17 Sep 2018 13:07:59 +0000 Subject: [PATCH] Fixing db importing with new mysql 5.7 installations --- apps/db_assembler/includes/functions.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/db_assembler/includes/functions.sh b/apps/db_assembler/includes/functions.sh index 9bc3b82de..e79802d82 100644 --- a/apps/db_assembler/includes/functions.sh +++ b/apps/db_assembler/includes/functions.sh @@ -28,8 +28,17 @@ function dbasm_mysqlExec() { read -p "Insert mysql user:" PROMPT_USER read -p "Insert mysql pass:" -s PROMPT_PASS export MYSQL_PWD=$PROMPT_PASS - + retval=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "$command") + if [[ $? -ne 0 ]]; then + err=$("$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "$command" 2>&1 ) + # it happens on new mysql 5.7 installations + # since mysql_native_password is explicit now + if [[ "$err" == *"Access denied"* ]]; then + echo "Setting mysql_native_password for $PROMPT_USER ..." + sudo "$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "ALTER USER '${PROMPT_USER}'@'localhost' IDENTIFIED WITH mysql_native_password BY '${PROMPT_PASS}';" + fi + fi # create configured account if not exists "$DB_MYSQL_EXEC" -h "$MYSQL_HOST" -u "$PROMPT_USER" $options -e "CREATE USER '${MYSQL_USER}'@'${MYSQL_HOST}' IDENTIFIED BY '${MYSQL_PASS}' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0;"