Skip to content

Commit

Permalink
Grant ALL PRIVILEGES to mysqlrouter user (#211)
Browse files Browse the repository at this point in the history
Needed for mysqlrouter refactoring: canonical/mysql-router-k8s-operator#51
  • Loading branch information
carlcsaposs-canonical authored Apr 21, 2023
1 parent f9bae23 commit a98b76c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/charms/mysql/v0/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def wait_until_mysql_connection(self) -> None:

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 21
LIBPATCH = 22

UNIT_TEARDOWN_LOCKNAME = "unit-teardown"

Expand Down Expand Up @@ -1167,7 +1167,7 @@ def grant_privileges_to_user(
raise MySQLGrantPrivilegesToUserError("Failed to get cluster primary address")

grant_privileges_commands = (
f"shell.connect('{self.cluster_admin_user}:{self.cluster_admin_password}@{cluster_primary}')",
f"shell.connect('{self.server_config_user}:{self.server_config_password}@{cluster_primary}')",
f"session.run_sql(\"GRANT {', '.join(privileges)} ON *.* TO '{username}'@'{hostname}'{' WITH GRANT OPTION' if with_grant_option else ''}\")",
)

Expand Down
2 changes: 1 addition & 1 deletion src/relations/mysql_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _on_database_requested(self, event: DatabaseRequestedEvent) -> None:
if "mysqlrouter" in extra_user_roles:
self.charm._mysql.upgrade_user_for_mysqlrouter(db_user, "%")
self.charm._mysql.grant_privileges_to_user(
db_user, "%", ["CREATE USER"], with_grant_option=True
db_user, "%", ["ALL PRIVILEGES"], with_grant_option=True
)

logger.info(f"Created user for app {remote_app}")
Expand Down

0 comments on commit a98b76c

Please sign in to comment.