From a3504f2668dbd1476366803926715d67101e88f6 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 28 Oct 2020 20:50:42 +0530 Subject: [PATCH] Revert "feat(frappe-worker): update user query for mariadb galera" --- build/common/commands/new.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/build/common/commands/new.py b/build/common/commands/new.py index d1452320..10fce846 100644 --- a/build/common/commands/new.py +++ b/build/common/commands/new.py @@ -83,17 +83,25 @@ def main(): mysql_command = ["mysql", f"-h{db_host}", f"-u{db_root_username}", f"-p{mariadb_root_password}", "-e"] # Drop User if exists - command = mysql_command + [f"DROP USER IF EXISTS '{db_name}'; FLUSH PRIVILEGES;"] + command = mysql_command + [f"DROP USER IF EXISTS '{db_name}'@'%'; FLUSH PRIVILEGES;"] run_command(command) - # Grant permission to database and set password + # update User's host to '%' required to connect from any container + command = mysql_command + [f"UPDATE mysql.user SET Host = '%' where User = '{db_name}'; FLUSH PRIVILEGES;"] + run_command(command) + + # Set db password + command = mysql_command + [f"ALTER USER '{db_name}'@'%' IDENTIFIED BY '{db_password}'; FLUSH PRIVILEGES;"] + run_command(command) + + # Grant permission to database grant_privileges = "ALL PRIVILEGES" # for Amazon RDS if config.get(RDS_DB) or site_config.get(RDS_DB): grant_privileges = RDS_PRIVILEGES - command = mysql_command + [f"GRANT {grant_privileges} ON `{db_name}`.* TO '{db_name}'@'%' IDENTIFIED BY '{db_password}'; FLUSH PRIVILEGES;"] + command = mysql_command + [f"GRANT {grant_privileges} ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"] run_command(command) if frappe.redis_server: