Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.
Original topic: 如何开通视图只读权限
[TiDB Usage Environment] Production Environment / Testing / Poc
[TiDB Version]
[Reproduction Path] What operations were performed when the issue occurred
[Encountered Issue: Issue Phenomenon and Impact]
As the title suggests, how can I create a new user and grant them read-only permissions on a view?
[Resource Configuration]
[Attachments: Screenshots/Logs/Monitoring]
grant show view on *.* to user
It won’t work. If you set this permission separately, you will get an error when you initiate SELECT * FROM VIEW
.
Permissions are as follows
mysql> show grants for v_ro@'%' ;
+--------------------------------------+
| Grants for v_ro@% |
+--------------------------------------+
| GRANT SHOW VIEW ON *.* TO 'v_ro'@'%' |
+--------------------------------------+
1 row in set (0.00 sec)
Error is as follows
mysql> show grants;
+--------------------------------------+
| Grants for User |
+--------------------------------------+
| GRANT SHOW VIEW ON *.* TO 'v_ro'@'%' |
+--------------------------------------+
1 row in set (0.00 sec)
mysql> select * from view_XXX ;
ERROR 1142 (42000): SELECT command denied to user 'v_ro'@'%' for table 'view_XXX'
mysql>
The tables involved in the view must have query permissions.
I have many views, and there are also many tables involved. Do I still need to add select query permissions one by one?
You should grant permissions on the tables within the view.
If strict control is not necessary, just grant select permissions to all tables. If you need to strictly control access to each table, you will have to identify and manage them one by one.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.