diff options
-rwxr-xr-x | docker/instance_init.sh | 6 | ||||
-rw-r--r-- | resources/bin/initDB.sh | 6 | ||||
-rw-r--r-- | resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql | 8 |
3 files changed, 8 insertions, 12 deletions
diff --git a/docker/instance_init.sh b/docker/instance_init.sh index 6c289657..7e5fcf31 100755 --- a/docker/instance_init.sh +++ b/docker/instance_init.sh @@ -26,9 +26,9 @@ function migrate_database { } -cd /service -if [ ! -f dbexist.txt ]; then - echo 1 > dbexist.txt +GET_NSLCM_DB="show databases like 'vfcnfvolcm';" +NSLCM_DB=`mysql -u$MYSQL_ROOT_USER -p$MYSQL_ROOT_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP -e "GET_NSLCM_DB"` +if [[ "$NSLCM_DB" == "" ]]; then create_database migrate_database fi diff --git a/resources/bin/initDB.sh b/resources/bin/initDB.sh index 01bb1561..7c0fa02a 100644 --- a/resources/bin/initDB.sh +++ b/resources/bin/initDB.sh @@ -26,10 +26,10 @@ sql_path=$HOME/../ mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -P$MYSQL_PORT -h$MYSQL_IP <$sql_path/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql sql_result=$? if [ $sql_result -ne 0 ] ; then - echo "failed to create vfcnfvolcm database" + echo "Failed to create vfcnfvolcm database" exit 1 -elif [ $sql_result -eq 0 ]; then - echo "create vfcnfvolcm database successfully" +else + echo "Create vfcnfvolcm database successfully" exit 0 fi diff --git a/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql b/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql index 94e630b5..bd90a1fa 100644 --- a/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql +++ b/resources/dbscripts/mysql/vfc-nfvo-lcm-createdb.sql @@ -14,14 +14,10 @@ -- limitations under the License. -- -/******************drop old database and user***************************/ +/******************create database and user***************************/ use mysql; -drop database IF EXISTS vfcnfvolcm; -delete from user where User='vfcnfvolcm'; -FLUSH PRIVILEGES; +create database if not exists vfcnfvolcm CHARACTER SET utf8; -/******************create new database and user***************************/ -create database vfcnfvolcm CHARACTER SET utf8; GRANT ALL PRIVILEGES ON vfcnfvolcm.* TO 'vfcnfvolcm'@'%' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON mysql.* TO 'vfcnfvolcm'@'%' IDENTIFIED BY 'vfcnfvolcm' WITH GRANT OPTION; |