fix: mysql db commands with subprocess

This commit is contained in:
Revant Nandgaonkar
2020-07-10 19:21:59 +05:30
parent 4598cb24f4
commit 21e2b13955
3 changed files with 12 additions and 7 deletions

View File

@@ -97,6 +97,10 @@ def main():
mysql_command = ["mysql", f"-h{db_host}", f"-u{mariadb_root_username}", f"-p{mariadb_root_password}", "-e"]
# Drop User if exists
command = mysql_command + [f"DROP USER IF EXISTS '{db_name}'@'%'; FLUSH PRIVILEGES;"]
run_command(command)
# 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)
@@ -106,7 +110,7 @@ def main():
run_command(command)
# Grant permission to database
command = mysql_command + [f"GRANT ALL PRIVILEGES ON \`{db_name}\`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"]
command = mysql_command + [f"GRANT ALL PRIVILEGES ON `{db_name}`.* TO '{db_name}'@'%'; FLUSH PRIVILEGES;"]
run_command(command)
if frappe.redis_server: