From a609e06b3c04fa2b4bcab7d37ac0339246e916b3 Mon Sep 17 00:00:00 2001 From: Christian Zagrodnick Date: Mon, 7 Mar 2022 10:29:28 +0100 Subject: [PATCH] make mysql compatible to mysql 8 This may break older mysql so the query can be overridden now #242 --- CHANGES.md | 2 ++ src/batou/lib/mysql.py | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6da4aab94..487d6be93 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,8 @@ `./batou migrate`. ([#185](https://github.com/flyingcircusio/batou/issues/185)) +- Support creating users in MySQL ≥8. + ([#242](https://github.com/flyingcircusio/batou/issues/242)) 2.3b3 (2021-11-30) ------------------ diff --git a/src/batou/lib/mysql.py b/src/batou/lib/mysql.py index 7cd0db997..880507f97 100644 --- a/src/batou/lib/mysql.py +++ b/src/batou/lib/mysql.py @@ -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("""\ @@ -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):