# mysql\_user issues handling privileges with wildcards

**URL:** <https://forum.ansible.com/t/mysql-user-issues-handling-privileges-with-wildcards/13190>\
**Category:** Ansible Project\
**Created:** [July 24, 2013, 8:34pm UTC](https://forum.ansible.com/t/mysql-user-issues-handling-privileges-with-wildcards/13190 "2013-07-24T20:34:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesus\_Garcia\_Crespo](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@Jesus\_Garcia\_Crespo](https://forum.ansible.com/u/Jesus_Garcia_Crespo)\
**Post date:** [July 24, 2013, 8:34pm UTC](https://forum.ansible.com/t/mysql-user-issues-handling-privileges-with-wildcards/13190/1 "2013-07-24T20:34:05Z")

</div>

Hi everyone!

Given the following playbook: [http://hastebin.com/pibujawasi](http://hastebin.com/pibujawasi) - I’ve found  
that the mysql\_user module is not escaping properly database names with  
wildcards in it, e.g.: foobar\_version%

This is the output of the playbook previously mentioned,  
including the Python traceback: [http://hastebin.com/fafepiseda](http://hastebin.com/fafepiseda)

mysql\_user tries to remove any privilege from the user if it doesn’t appear in  
the new specification. privileges\_revoke() is invoked, which produces a query  
where the database name is not escaped as expected as it has a wildcard in it.  
This is how the query looks like:

REVOKE ALL PRIVILEGES ON foobar\_version%.\* FROM ‘username’@‘localhost’;

For some reason privileges\_get() removes the grave accent (`) from the database  
name, which is read from the output of SHOW GRANTS. That happens in the  
line 222:

db = res.group(2).replace(‘`’, ‘’)

If I remove the call to replace(), the module works as expected as the query  
produced is:

REVOKE ALL PRIVILEGES ON `foobar\_version%`.\* FROM ‘username’@‘localhost’;

Do you know why is the grave accent being removed by mysql\_user?  
Is safe to stop doing that?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 25, 2013, 6:42am UTC](https://forum.ansible.com/t/mysql-user-issues-handling-privileges-with-wildcards/13190/2 "2013-07-25T06:42:42Z")

</div>

Sounds like this should be an issue filed in github 🙂
