is it possible to create a MySQL Username that has permissions to only access data in a table with a certain value
e.g like the ‘root’ username a ‘user1’ which can access
ID | USER_ID | TEXT
======+==============+===============
1 | 1 | This is text a
2 | 1 | This is text b
3 | 2 | This is text c (hidden)
4 | 1 | This is text d
So that they would only be able to see ID 1,2 and 4 and the others would have no access, no results, or something like that?
You can do this by creating a view which excludes the records that MySQL user should not have access to:
The idea is to revoke all privileges from the database, which includes the underlying table, then grant
SELECTprivileges back to the view only. The privilege will not be transferred to the underlying table, and the user will therefore not have access to any records that are not exposed by the view.