tags:

views:

82

answers:

2

The following does work as expected:

GRANT ALL ON *.* to 'someuser'@'%' identified by 'somepass';

Can I use wildcards for Database name like:

GRANT ALL ON someDB*.* to 'someuser'@'%' identified by 'somepass';
+2  A: 

From MySQL 5.1 documentation:

The "_" and "%" wildcards are allowed when specifying database names in GRANT statements that grant privileges at the global or database levels. This means, for example, that if you want to use a "_" character as part of a database name, you should specify it as "\_" in the GRANT statement, to prevent the user from being able to access additional databases matching the wildcard pattern; for example, GRANT ... ON 'foo\_bar'.* TO ....

Igor Klimer
A: 

You can use this code:

GRANT ALL ON `someDB_%`.* TO 'someuser'@'%' IDENTIFIED BY 'somepass';

You have to use "`" as character to specify wildcard on database name.

Matteo Alessani