Reputation: 701
I have a set of databeses with names like abc_base_1, abc_base_2, abc_base_3 abc_base_n.
I'd like to grant all privileges on all tables of all this databases to one non root user.
Generally, it seems that abc_ is a common prefix of group.
Questions:
Is mysql has database groups? If yes - how to define them (something special or it just has to have same name prefix (like abc))?
Is it possible to grant privileges on group of databases (or databases with names starts with abc prefix)? If yes - how to grant?
Is this permissions distributes dynamically for all new databases, that has the same name prefix or I should grant permissions all the time, when new databases are created.
Upvotes: 2
Views: 2620
Reputation: 701
I've found solution.
Privileges should be granted like this:
GRANT ALL PRIVILEGES ON `abc\_%` . * TO 'someuser'@'localhost';
This expression provides the following rights:
abc_
abc_
abc_
but created by other users.Upvotes: 1
Reputation:
Yes. You can grant permissions to a group of MySQL databases identified by a LIKE
wildcard:
mysql> GRANT ALL ON `abc\_%`.* TO username@localhost;
Permissions are checked when a user attempts to access the database -- you do not need to repeat this GRANT
statement when databases are created.
Upvotes: 5