Try to set mysql user password in 2 different ways
so some versions of MySQL and/or MariaDB do not agree as to how the password should be set? weird, but oh well, hopefully this works everywhere...
This commit is contained in:
parent
d744257af6
commit
96f950d958
|
@ -70,12 +70,15 @@ def create_user(c, name, host='localhost', password=None, checkfirst=True):
|
||||||
if not checkfirst or not user_exists(c, name, host):
|
if not checkfirst or not user_exists(c, name, host):
|
||||||
sql(c, "CREATE USER '{}'@'{}';".format(name, host))
|
sql(c, "CREATE USER '{}'@'{}';".format(name, host))
|
||||||
if password:
|
if password:
|
||||||
# TODO: pretty sure this can go away, but leaving until certain
|
# supposedly this is the new way to do it
|
||||||
# sql(c, "SET PASSWORD FOR '{}'@'{}' = PASSWORD('{}');".format(
|
result = sql(c, "ALTER USER '{}'@'{}' IDENTIFIED BY '{}';".format(
|
||||||
# name, host, password), hide=True, echo=False)
|
|
||||||
sql(c, "ALTER USER '{}'@'{}' IDENTIFIED BY '{}';".format(
|
|
||||||
name, host, password),
|
name, host, password),
|
||||||
echo=False)
|
echo=False, hide=True, warn=True)
|
||||||
|
if result.failed: # but this may fail for older systems
|
||||||
|
# in which case we try it the old way
|
||||||
|
sql(c, "SET PASSWORD FOR '{}'@'{}' = PASSWORD('{}');".format(
|
||||||
|
name, host, password),
|
||||||
|
echo=False, hide=True)
|
||||||
|
|
||||||
|
|
||||||
def db_exists(c, name):
|
def db_exists(c, name):
|
||||||
|
|
Loading…
Reference in a new issue