Skip to content

Commit

Permalink
Merge pull request #287 from flyingcircusio/mysql8-fix
Browse files Browse the repository at this point in the history
make mysql compatible to mysql 8
  • Loading branch information
ctheune authored Mar 7, 2022
2 parents aaa5563 + 6ceec48 commit 3099041
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
`./batou migrate`.
([#185](https://github.com/flyingcircusio/batou/issues/185))

- Support creating users in MySQL ≥8.
([#242](https://github.com/flyingcircusio/batou/issues/242))

- Allow to check if an `Address` is configured for IPv4 resp. IPv6 using the
attributes `require_v4` resp. `require_v6`.


2.3b3 (2021-11-30)
------------------

Expand Down
16 changes: 9 additions & 7 deletions src/batou/lib/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class User(Component):
allow_from_hostname = "localhost"
admin_password = None

SET_PASSWORD_QUERY = """
SET PASSWORD FOR
'{{component.user}}'@'{{component.allow_from_hostname}}' =
'{{component.password}}';
"""

def configure(self):

create = self.expand("""\
Expand All @@ -105,13 +111,9 @@ def configure(self):
""")
self += Command(
create, unless=create_unless, admin_password=self.admin_password)

set_password = self.expand("""\
SET PASSWORD FOR
'{{component.user}}'@'{{component.allow_from_hostname}}' =
PASSWORD('{{component.password}}');
""")
self += Command(set_password, admin_password=self.admin_password)
self += Command(
self.expand(self.SET_PASSWORD_QUERY),
admin_password=self.admin_password)


class Grant(Command):
Expand Down

0 comments on commit 3099041

Please sign in to comment.