I create an user called abc. Now I need to grant read privilege to him. But he should be get read privilege only for the views in database. How can I implement this?
Asked
Active
Viewed 79 times
0
-
1What is a `grantion`? – Kermit Feb 14 '14 at 18:45
2 Answers
3
GRANT SELECT ON database.view TO 'abc'@'localhost';
Also, there is a neat trick, which (combined with SHOW FULL TABLES IN database_name WHERE TABLE_TYPE LIKE 'VIEW';
) will allow you to generate code for all views you need.
-
Thank you very much. Here I have more than one view. I need to give priviledges to all the views. – Isuru Herath Feb 14 '14 at 18:08
-
1@IsuruHerath You can easily do this with a script. Simply get list of all views `SHOW FULL TABLES IN database_name WHERE TABLE_TYPE LIKE 'VIEW';` and store in array, and then go through array giving the permissions on each item! For example, you can do this with bash or php – Alexander Feb 14 '14 at 18:27
-
-
@IsuruHerath tell the person, who asked you, that this is impossible – Alexander Feb 14 '14 at 18:35
-
@IsuruHerath have you finished your task? Was I right, when told you, that this can't be done? – Alexander Feb 22 '14 at 18:49
0
You can use GRANT http://dev.mysql.com/doc/refman/5.1/en/grant.html#grant-privileges
GRANT SELECT ON db2.invoice TO 'jeffrey'@'localhost';

Hett
- 3,484
- 2
- 34
- 51