You can use table name patterns for GRANT in MySQL

Is it possible in MySQL to do GRANT for a user in a set of tables in a database, for example. Allow CREATE AND DROP ing the names of some tables, but not others?

None of them work:

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

and the MySQL manual does not seem to give an answer anyway.

+3
source share
3 answers

The only template that works in the GRANT statement: *

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

All or one; there is no way to dynamically map table names to privileges granted.

+4
source

Nope. You can separate table names with commas, but you cannot use wildcards in GRANT.

+2
source

. ( , ) CREATE VIEW test SELECT * from originaldatabase.tablename ...

NewDatabase whith GRANT NewDatabase. * To 'testuser' @'localhost'

, .

, USER() WHERE :

: * from original.customer, mysql_user = USER()

In the original order, you should have a mysql_user column and each row that the user under test can see should have testuser @localhost as an entry

The tester will see all created views in the form of tables in the database 'test'

+1
source

Source: https://habr.com/ru/post/1718750/


All Articles