Can wildcards be used on tablenames for a GRANT in MySQL

后端 未结 3 1012
再見小時候
再見小時候 2021-01-19 18:19

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 o

3条回答
  •  不知归路
    2021-01-19 19:07

    Create a new empty database . Give it access to the original database ( use a user who allready have access to original database ) in this new database CREATE VIEW test as SELECT * from originaldatabase.tablename WHERE conditions...

    Then give test user access to NewDatabase whith GRANT select on NewDatabase.* to 'testuser'@'localhost'

    Then only create views for the tables you want testuser to access.

    Also remember you can do a USER() in the WHERE part of the view:

    example: create view test as select * from original.customer where mysql_user = USER()

    In the original.customer you must then have a column 'mysql_user' and every row the test user is allowed to see must have testuser@localhost as a entry

    The testuser will see all the created views as tables in the database 'test'

提交回复
热议问题