tags:

views:

412

answers:

2

Is it possible in MySQL to do a GRANT to a user on a set of tables within a database, e.g. to allow CREATE AND DROP ing of some table names but not others?

Neither of these seem to work:

GRANT SELECT ON  `testdb`.`%_testing` TO  'wildcardtest'@'localhost';
GRANT SELECT ON  `testdb`.`testing%` TO  'wildcardtest'@'localhost';

and the MySQL manual doesn't seem to give an answer either way.

A: 

Nope. You can separate table names with commas but can't use wildcards in a GRANT.

Justin Grant
+1  A: 

The only wildcard that works in the GRANT statement is *

GRANT SELECT ON `testdb`.* TO 'user'@'localhost';
GRANT SELECT ON *.* TO 'privilegeduser'@'localhost';

It's all or one; there's no facility for dynamic matching of table names to granted privileges.

Ian Clelland