1

I'm trying to grant access one user to many db that have been created on my system like this:

dbUser_1 dbUser_2 ...

and so on.

I can use GRANT SELECT, INSERT, UPDATE ON `dbUser\_%`.* TO 'kenny'@'localhost'; To let kenny user to insert, select and update ALLL the table of each db.

I'm looking for make something like this: ATENTION, this don't work: GRANT SELECT, INSERT, UPDATE ON `dbUser\_%`.*`bill` TO 'kenny'@'localhost';

To let kenny get access to all the bill tables on each db.

¿It is possible?

I'm using mysql. Thanks in advance.

2 Answers 2

0

You can use this:

GRANT SELECT, INSERT, UPDATE ON DBNAME.TABLE_NAME TO USERNAME

So it will be something like this:

GRANT SELECT, INSERT, UPDATE ON dbUser\_%.* TO 'kenny'@'localhost';

For more check: https://dev.mysql.com/doc/refman/5.7/en/grant.html

Update: When specifying a table level privilege, wildcards in the DB are treated as the character _ and %. They are not wildcards anymore. See the GRANT documentation under "Object Quoting Guidelines" (@mhost)

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Voli, this answer don't works for me because i'm looking for Grant access to all the db with the same prefix (dbUser_1, dbUser_2 ...) but only one of the tables of each database (bill) When I try to Grant with wildcards, the system tell me that the "Table doesn't exist"... I need this solution to let the future db of the sistem be updated by this user. Thanks for your aswer.
I can only redirect you to this: stackoverflow.com/questions/2668591/… Sorry that I couldn't help you with this :)
0

There is another option:

GRANT ALL PRIVILEGES ON `%`.`my_table` TO `myuser`@`myhost`;
REVOKE INSERT,CREATE,DROP,UPDATE,DELETE,ALTER,REFERENCES,CREATE VIEW,TRIGGER,INDEX,SHOW VIEW ON `%`.`my_table` FROM `myuser`@`myhost`;

I had today similar problem and same error as you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.