Module: kamailio
Branch: master
Commit: c0879add55bef77703f2259f224b4a1f954cd8bf
URL:
https://github.com/kamailio/kamailio/commit/c0879add55bef77703f2259f224b4a1…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2019-10-22T10:49:18+02:00
kamdbctl: split create user and grant access statements for mysql
- MySQL 8 doesn't support all in one statement
---
Modified: utils/kamctl/kamdbctl.mysql
---
Diff:
https://github.com/kamailio/kamailio/commit/c0879add55bef77703f2259f224b4a1…
Patch:
https://github.com/kamailio/kamailio/commit/c0879add55bef77703f2259f224b4a1…
---
diff --git a/utils/kamctl/kamdbctl.mysql b/utils/kamctl/kamdbctl.mysql
index 6103705bc0..e8f8d2e861 100644
--- a/utils/kamctl/kamdbctl.mysql
+++ b/utils/kamctl/kamdbctl.mysql
@@ -160,8 +160,10 @@ kamailio_db_grant () # pars: <database name>
minfo "granting privileges to database $1 ..."
# Users: kamailio is the regular user, kamailioro only for reading
- sql_query "" "GRANT ALL PRIVILEGES ON $1.* TO
'${DBRWUSER}'@'$DBHOST' IDENTIFIED BY '$DBRWPW';
- GRANT SELECT ON $1.* TO '${DBROUSER}'@'$DBHOST' IDENTIFIED BY
'$DBROPW';"
+ sql_query "" "CREATE USER '${DBRWUSER}'@'$DBHOST'
IDENTIFIED BY '$DBRWPW';
+ GRANT ALL PRIVILEGES ON $1.* TO '${DBRWUSER}'@'$DBHOST';
+ CREATE USER '${DBROUSER}'@'$DBHOST' IDENTIFIED BY '$DBROPW';
+ GRANT SELECT ON $1.* TO '${DBROUSER}'@'$DBHOST';"
if [ $? -ne 0 ] ; then
merr "granting privileges to database $1 failed!"
@@ -169,8 +171,10 @@ kamailio_db_grant () # pars: <database name>
fi
if [ "$DBHOST" != "localhost" ] ; then
- sql_query "" "GRANT ALL PRIVILEGES ON $1.* TO
'$DBRWUSER'@'localhost' IDENTIFIED BY '$DBRWPW';
- GRANT SELECT ON $1.* TO '$DBROUSER'@'localhost' IDENTIFIED BY
'$DBROPW';"
+ sql_query "" "CREATE USER '$DBRWUSER'@'localhost'
IDENTIFIED BY '$DBRWPW';
+ GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER'@'localhost';
+ CREATE USER '$DBROUSER'@'localhost' IDENTIFIED BY '$DBROPW';
+ GRANT SELECT ON $1.* TO '$DBROUSER'@'localhost';"
if [ $? -ne 0 ] ; then
merr "granting localhost privileges to database $1 failed!"
exit 1
@@ -178,8 +182,10 @@ kamailio_db_grant () # pars: <database name>
fi
if [ ! -z "$DBACCESSHOST" ] ; then
- sql_query "" "GRANT ALL PRIVILEGES ON $1.* TO
'$DBRWUSER'@'$DBACCESSHOST' IDENTIFIED BY '$DBRWPW';
- GRANT SELECT ON $1.* TO '$DBROUSER'@'$DBACCESSHOST' IDENTIFIED BY
'$DBROPW';"
+ sql_query "" "CREATE USER '$DBRWUSER'@'$DBACCESSHOST'
IDENTIFIED BY '$DBRWPW';
+ GRANT ALL PRIVILEGES ON $1.* TO '$DBRWUSER'@'$DBACCESSHOST';
+ CREATE USER '$DBROUSER'@'$DBACCESSHOST' IDENTIFIED BY
'$DBROPW';
+ GRANT SELECT ON $1.* TO '$DBROUSER'@'$DBACCESSHOST';"
if [ $? -ne 0 ] ; then
merr "granting access host privileges to database $1 failed!"
exit 1