I use mysql c++ wrapper in client side to connect to mysql server. When user establishes connection to mysql server I want to know whether the user have privileges like root (i.e. GRANT ALL PRIVILEGES ON . TO 'username'@'%' WITH GRANT OPTION).
The 'SHOW GRANTS FOR CURRENT_USER' query gives grants for current user, but i need to parse the string and compare to know whether the current user have privileges like root. I am looking for an alternative options.
Regards,
Devara Gudda
views:
51answers:
1
A:
You could query the various tables in mysql.* and compare the permissions fields between the accounts. Of course, you'd have to account for variances in the host/user fields, as MySQL considers root@localhost to be a completely different account than root@% and [email protected] etc..
select * from mysql.TABLE where User in ('root', 'youraccount', 'someotheraccount');
where TABLE is 'user', 'db', 'func', etc...
Marc B
2010-03-18 04:09:40
This is definetely easier to parse than SHOW GRANTS, but you need read access to the mysql database - which may or may not be a drawback.
titanoboa
2010-03-18 10:26:17