diff --git a/changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml b/changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml new file mode 100644 index 00000000000..50fd48ff980 --- /dev/null +++ b/changelogs/fragments/64059-mysql_user_fix_password_comparison.yaml @@ -0,0 +1,2 @@ +bugfixes: +- mysql_user - make sure current_pass_hash is a string before using it in comparison (https://github.com/ansible/ansible/issues/60567). diff --git a/lib/ansible/modules/database/mysql/mysql_user.py b/lib/ansible/modules/database/mysql/mysql_user.py index 1ca59940718..f999abb74ae 100644 --- a/lib/ansible/modules/database/mysql/mysql_user.py +++ b/lib/ansible/modules/database/mysql/mysql_user.py @@ -390,6 +390,8 @@ def user_mod(cursor, user, host, host_all, password, encrypted, FROM mysql.user WHERE user = %%s AND host = %%s """ % (colA[0], colA[0], colB[0], colB[0]), (user, host)) current_pass_hash = cursor.fetchone()[0] + if isinstance(current_pass_hash, bytes): + current_pass_hash = current_pass_hash.decode('ascii') if encrypted: encrypted_password = password