ansible-role-mysql
ansible-role-mysql copied to clipboard
Fix error in query with sql_mode ANSI_QUOTES
When MySQL is configured to use sql_mode ANSI_QUOTES, the query in tasks/secure-installation.yml fails:
TASK [geerlingguy.mysql : Get list of hosts for the anonymous user.] **************************************************************************************************************************************
fatal: [0.0.0.0]: FAILED! => {"changed": false, "cmd": ["mysql", "-NBe", "SELECT Host FROM mysql.user WHERE User = \"\""], "delta": "0:00:00.015942", "end": "2022-08-10 18:27:01.544215", "msg": "non-zero return code", "rc": 1, "start": "2022-08-10 18:27:01.528273", "stderr": "ERROR 1054 (42S22) at line 1: Unknown column '' in 'where clause'", "stderr_lines": ["ERROR 1054 (42S22) at line 1: Unknown column '' in 'where clause'"], "stdout": "", "stdout_lines": []}
This happens because with this mode mysql treats " as an identifier quote character (like the ` quote character) and not as a string quote character.