0

I'd like to grant for example an select permission for specific user in all databases on my server started by WA_ for example in my server

I make the following syntax but it dosent work

grant select on `wa\_%`.`mytable` 
to 'myuser'@'localhost' 
identified by '123456';

but it gives me this error

Table wa_%.mytable' doesn't exist

KimoKono
  • 91
  • 2
  • 5

2 Answers2

3

MySQL doesn´t allow this type of grants, you can only have wildcards in the database name if you grant privileges on the database or global level. See below exceprt from the 5.5 manual:

The “_” and “%” wildcards are permitted when specifying database names in GRANT statements that grant privileges at the global or database levels.

So for example this will work, because you grant select on database level:

grant select on `wa\_%`.* 
to 'myuser'@'localhost' 
identified by '123456';

In your example you try to grant access to specific table using wildcard schema name which is not supported by MySQL.

Flo Doe
  • 5,197
  • 2
  • 19
  • 18
  • thanks can u send to me the links to read more about it ??? because i use the wild card on the name of database as the following GRANT SELECT ON `wa\_%` . * TO 'myuser'@'localhost' identified by '123456'; but it gives the permission on all the database table – KimoKono Jul 16 '13 at 11:26
  • Hi, yes, this is the only way you can use wildcards for the schema name in grant syntax. Allow access to all tables within schema, you can´t specify grants which have wildcard-schemaname and spercific table. Read more about it here: http://dev.mysql.com/doc/refman/5.5/en/grant.html – Flo Doe Jul 17 '13 at 07:04
-1

You can try this:

GRANT SELECT ON  `wa\_%` . * TO  'myuser'@'localhost' identified by '123456';
Sathish D
  • 4,854
  • 31
  • 44