diff --git a/mysql/user.sls b/mysql/user.sls
index a2f6c5334e54f944a858207c94de205394c223b8..e729bf8035946f4fc51a829f5e73f7a4a3f53d73 100644
--- a/mysql/user.sls
+++ b/mysql/user.sls
@@ -112,6 +112,7 @@ include:
{% endif %}
- user: {{ name }}
- host: '{{ host }}'
+ - escape: {{ db['escape'] | default(True) }}
- connection_host: '{{ mysql_host }}'
- connection_user: '{{ mysql_salt_user }}'
{% if mysql_salt_pass -%}
diff --git a/pillar.example b/pillar.example
index 0dfa2b092aabe729329e93ee37e39a267a405fac..006b2e95dec9bacd1728bc892fab1817e5232812 100644
--- a/pillar.example
+++ b/pillar.example
@@ -106,6 +106,7 @@ mysql:
databases:
- database: foo
grants: ['select', 'insert', 'update']
+ escape: True
- database: bar
grants: ['all privileges']
bob:
@@ -117,9 +118,14 @@ mysql:
ssl-ISSUER: Name
ssl-CIPHER: Cipher
databases:
- - database: foo
+ # https://github.com/saltstack/salt/issues/41178
+ # If you want to refer to databases using wildcards, turn off escape so
+ # the renderer does not escape them, enclose the string in '`' and
+ # use two '%'
+ - database: '`foo\_%%`'
grants: ['all privileges']
grant_option: True
+ escape: False
- database: bar
table: foobar
grants: ['select', 'insert', 'update', 'delete']