Sunday, April 18, 2010

Grant permission - Checking

If we want to know what permissions have grant to the user,
we can use the below command :

mysql>show grants for 'root';
Grants for Root@%
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION

Reference :
http://dev.mysql.com/doc/refman/4.1/en/show-grants.html

if we want to know what user been grant to table, we can use the below method
mysql> select * mysql.tables_priv where table_name='mytable';


+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
| Host | Db | User | Table_name | Grantor | Timestamp | Table_priv | Column_priv |
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+
| % | testdb | test_user | mytable | root@127.0.0.1 | 2009-01-08 18:38:14 | Select,Delete | |
| % | testdb | test_user2 | mytable | | 2010-03-23 16:09:00 | Select | |
+------+--------+---------------+---------------------+----------------+---------------------+---------------+-------------+

No comments: