From a72340f91c9d12c9bdcdf8d3b514ac01ec177be7 Mon Sep 17 00:00:00 2001 From: andreasgeissler Date: Wed, 17 Mar 2021 09:49:59 +0100 Subject: [SDNC] Check existance of DB user before creation When installing SDNC in a local DB, the execution of the DB initialisation job fails as the user already exists and granting the privileges to the DB is not executed. This patch will only create the user and DB if not already present. Issue-ID: OOM-2705 Signed-off-by: andreasgeissler Change-Id: Iabfc90829cea1f98181caf3367c8f2b78de96c7f --- kubernetes/sdnc/resources/config/bin/installSdncDb.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kubernetes/sdnc/resources/config') diff --git a/kubernetes/sdnc/resources/config/bin/installSdncDb.sh b/kubernetes/sdnc/resources/config/bin/installSdncDb.sh index 11ed7f45bf..42abf54444 100755 --- a/kubernetes/sdnc/resources/config/bin/installSdncDb.sh +++ b/kubernetes/sdnc/resources/config/bin/installSdncDb.sh @@ -37,8 +37,8 @@ SDNC_DB_DATABASE=${SDNC_DB_DATABASE} # Create tablespace and user account mysql -h ${MYSQL_HOST} -u root -p${MYSQL_PASSWORD} mysql <<-END CREATE DATABASE IF NOT EXISTS ${SDNC_DB_DATABASE}; -CREATE USER '${SDNC_DB_USER}'@'localhost' IDENTIFIED BY '${SDNC_DB_PASSWORD}'; -CREATE USER '${SDNC_DB_USER}'@'%' IDENTIFIED BY '${SDNC_DB_PASSWORD}'; +CREATE USER IF NOT EXISTS '${SDNC_DB_USER}'@'localhost' IDENTIFIED BY '${SDNC_DB_PASSWORD}'; +CREATE USER IF NOT EXISTS '${SDNC_DB_USER}'@'%' IDENTIFIED BY '${SDNC_DB_PASSWORD}'; GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'localhost' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON ${SDNC_DB_DATABASE}.* TO '${SDNC_DB_USER}'@'%' WITH GRANT OPTION; flush privileges; -- cgit 1.2.3-korg