From 604f797f0ecdc3d34ae031b971f61b2d7bc4e0b2 Mon Sep 17 00:00:00 2001 From: Andrew Klychkov Date: Thu, 23 Apr 2020 17:03:56 +0300 Subject: [PATCH] mysql_user: fix error No database selected --- .../fragments/225-mysql_user_fix_no_database_selected.yml | 2 ++ lib/ansible/modules/database/mysql/mysql_user.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/225-mysql_user_fix_no_database_selected.yml diff --git a/changelogs/fragments/225-mysql_user_fix_no_database_selected.yml b/changelogs/fragments/225-mysql_user_fix_no_database_selected.yml new file mode 100644 index 00000000000..1deda3ed5d1 --- /dev/null +++ b/changelogs/fragments/225-mysql_user_fix_no_database_selected.yml @@ -0,0 +1,2 @@ +bugfixes: +- mysql_user - fix the error No database selected (https://github.com/ansible/ansible/issues/68070). diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 28bea8ae797..0dcbc700f94 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -386,7 +386,7 @@ def user_mod(cursor, user, host, host_all, password, encrypted, new_priv, append # Replacing empty root password with new authentication mechanisms fails with error 1396 if e.args[0] == 1396: cursor.execute( - "UPDATE user SET plugin = %s, authentication_string = %s, Password = '' WHERE User = %s AND Host = %s", + "UPDATE mysql.user SET plugin = %s, authentication_string = %s, Password = '' WHERE User = %s AND Host = %s", ('mysql_native_password', encrypted_password, user, host) ) cursor.execute("FLUSH PRIVILEGES")