diff --git a/client/conf/db.properties.in b/client/conf/db.properties.in index 2f1dcf0d6b84..b0d07573dbf8 100644 --- a/client/conf/db.properties.in +++ b/client/conf/db.properties.in @@ -39,7 +39,7 @@ db.cloud.testWhileIdle=true db.cloud.timeBetweenEvictionRunsMillis=40000 db.cloud.minEvictableIdleTimeMillis=240000 db.cloud.poolPreparedStatements=false -db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' +db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' # CloudStack database SSL settings db.cloud.useSSL=false diff --git a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseCreator.java b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseCreator.java index 2281e1d2399e..7bf5cf627902 100644 --- a/engine/schema/src/main/java/com/cloud/upgrade/DatabaseCreator.java +++ b/engine/schema/src/main/java/com/cloud/upgrade/DatabaseCreator.java @@ -104,8 +104,10 @@ private static void initDB(String dbPropsFile, String rootPassword, String[] dat List queries = new ArrayList(); queries.add(String.format("drop database if exists `%s`", dbName)); queries.add(String.format("create database `%s`", dbName)); - queries.add(String.format("GRANT ALL ON %s.* to '%s'@`localhost` identified by '%s'", dbName, username, password)); - queries.add(String.format("GRANT ALL ON %s.* to '%s'@`%%` identified by '%s'", dbName, username, password)); + queries.add(String.format("CREATE USER IF NOT EXISTS %s@`localhost` identified by '%s'", username, password)); + queries.add(String.format("CREATE USER IF NOT EXISTS %s@`%%` identified by '%s'", username, password)); + queries.add(String.format("GRANT ALL ON %s.* to '%s'@`localhost`", dbName, username)); + queries.add(String.format("GRANT ALL ON %s.* to '%s'@`%%`", dbName, username)); for (String query : queries) { runQuery(host, port, rootPassword, query, dryRun); diff --git a/setup/db/create-database-simulator.sql b/setup/db/create-database-simulator.sql index 8924eda3ff5a..b61ce1b8d406 100644 --- a/setup/db/create-database-simulator.sql +++ b/setup/db/create-database-simulator.sql @@ -20,8 +20,8 @@ DROP DATABASE IF EXISTS `simulator`; CREATE DATABASE `simulator`; -GRANT ALL ON simulator.* to cloud@`localhost` identified by 'cloud'; -GRANT ALL ON simulator.* to cloud@`%` identified by 'cloud'; +GRANT ALL ON simulator.* to cloud@`localhost`; +GRANT ALL ON simulator.* to cloud@`%`; GRANT process ON *.* TO cloud@`localhost`; GRANT process ON *.* TO cloud@`%`; diff --git a/setup/db/create-database.sql b/setup/db/create-database.sql index 51f56565bf41..81e13f9fe229 100644 --- a/setup/db/create-database.sql +++ b/setup/db/create-database.sql @@ -55,10 +55,11 @@ DROP DATABASE IF EXISTS `cloud`; CREATE DATABASE `cloud`; -CREATE USER cloud identified by 'cloud'; +CREATE USER cloud@`localhost` identified by 'cloud'; +CREATE USER cloud@`%` identified by 'cloud'; -GRANT ALL ON cloud.* to cloud@`localhost` identified by 'cloud'; -GRANT ALL ON cloud.* to cloud@`%` identified by 'cloud'; +GRANT ALL ON cloud.* to cloud@`localhost`; +GRANT ALL ON cloud.* to cloud@`%`; GRANT process ON *.* TO cloud@`localhost`; GRANT process ON *.* TO cloud@`%`; diff --git a/utils/conf/db.properties b/utils/conf/db.properties index 2fd6910368a6..83051dbfca9d 100644 --- a/utils/conf/db.properties +++ b/utils/conf/db.properties @@ -44,7 +44,7 @@ db.cloud.testWhileIdle=true db.cloud.timeBetweenEvictionRunsMillis=40000 db.cloud.minEvictableIdleTimeMillis=240000 db.cloud.poolPreparedStatements=false -db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' +db.cloud.url.params=prepStmtCacheSize=517&cachePrepStmts=true&prepStmtCacheSqlLimit=4096&sessionVariables=sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' # usage database settings db.usage.username=cloud