GRANT with database name wildcard in MySQL?

JR Lawhorne picture JR Lawhorne · Apr 19, 2010 · Viewed 42.4k times · Source

I want to create a user 'projectA' that has the same permissions to every database named 'projectA_%'

I know its possible but MySQL doesn't like my syntax:

grant all on 'projectA\_%'.* to 'projectA'@'%';

Reference: http://dev.mysql.com/doc/refman/5.1/en/grant.html

Answer

JR Lawhorne picture JR Lawhorne · Apr 19, 2010

If I use back-tics instead of single quotes in the syntax, it appears to work just fine:

grant all on `projectA\_%`.* to `projectA`@`%`;