If I have a table called example. And I grant privileges like SELECT, INSERT, etc to subject1, subject2, subject3. How can I then as the owner of the table, view everyone and their privileges that I have given to example?
Asked
Active
Viewed 54 times
2 Answers
1
You could run a query against tables_priv
table in the mysql
database:
SELECT p.User
, p.Host
, p.Table_priv
, p.Grantor
FROM mysql.tables_priv p
WHERE p.Db = 'mydatabase'
AND p.Table_name = 'example'
ORDER by 1,2,3
This isn't everyone that has privileges on the table, if privileges were granted on the entire database, e.g.
GRANT SELECT ON mydatabase.* TO subject1@'%'
Those privileges would be in the db
table in the mysql
database. Global privileges granted to a user on all databases would be in the user
table.

spencer7593
- 106,611
- 15
- 112
- 140
0
The MySql schema for users and privileges is pretty vast complicated depending on how in depth you would like to get.
You can find all users from the users table (granted you have permissions). And you may find table/column privileges from these two columns: tables_priv and columns_priv
so you would want something like this:
select * from users
join tables_priv on users.user = tables_priv.user
Take note that the more information you want, the more you will need to expand this query.

James McDonnell
- 3,600
- 1
- 20
- 26
-
I would suggest that you read through the mysql documentation. It is pretty verbose. – James McDonnell Apr 11 '14 at 17:51