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 0000000000..1deda3ed5d --- /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/plugins/modules/database/mysql/mysql_user.py b/plugins/modules/database/mysql/mysql_user.py index edf3f11468..245510c130 100644 --- a/plugins/modules/database/mysql/mysql_user.py +++ b/plugins/modules/database/mysql/mysql_user.py @@ -441,7 +441,7 @@ def user_mod(cursor, user, host, host_all, password, encrypted, # 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")