snippetsqlMinor
how to "revoke" a "GRANT OPTION" from an mysql user/database?
Viewed 0 times
usergrantrevokedatabaseoptionmysqlhowfrom
Problem
i have a mysql installation with lots of users and grants. But one grant is unique, since its supposed to be a simple DB user and usually does not need GRANT privileges. However someone added it when the account where added. It looks like this:
I searched the net (and this site) for a solution on how to remove that "GRANT OPTION" thingy, without recreating the whole grant/account . so far without luck.
Is there really no way just to remove "this" privilege or right from that account ?
thanks in advance.
GRANT USAGE ON *.* TO 'freg2'@'%' IDENTIFIED BY PASSWORD '*XXXXX';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, \
REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, \
LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, \
CREATE ROUTINE, ALTER ROUTINE \
ON `freg2`.* TO 'freg2'@'%' WITH GRANT OPTION;I searched the net (and this site) for a solution on how to remove that "GRANT OPTION" thingy, without recreating the whole grant/account . so far without luck.
Is there really no way just to remove "this" privilege or right from that account ?
thanks in advance.
Solution
Just as usual...
The manual is also as always very helpful.
root@localhost:playground > grant select, grant option on playground.* to asdf@localhost identified by 'asdf';
Query OK, 0 rows affected (0.02 sec)
root@localhost:playground > show grants for asdf@localhost;
+-------------------------------------------------------------------------------------------------------------+
| Grants for asdf@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'asdf'@'localhost' IDENTIFIED BY PASSWORD '*7F0C90A004C46C64A0EB9DDDCE5DE0DC437A635C' |
| GRANT SELECT ON `playground`.* TO 'asdf'@'localhost' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
root@localhost:playground > revoke grant option on playground.* from asdf@localhost;
Query OK, 0 rows affected (0.00 sec)
root@localhost:playground > show grants for asdf@localhost;
+-------------------------------------------------------------------------------------------------------------+
| Grants for asdf@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'asdf'@'localhost' IDENTIFIED BY PASSWORD '*7F0C90A004C46C64A0EB9DDDCE5DE0DC437A635C' |
| GRANT SELECT ON `playground`.* TO 'asdf'@'localhost' |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)The manual is also as always very helpful.
Code Snippets
root@localhost:playground > grant select, grant option on playground.* to asdf@localhost identified by 'asdf';
Query OK, 0 rows affected (0.02 sec)
root@localhost:playground > show grants for asdf@localhost;
+-------------------------------------------------------------------------------------------------------------+
| Grants for asdf@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'asdf'@'localhost' IDENTIFIED BY PASSWORD '*7F0C90A004C46C64A0EB9DDDCE5DE0DC437A635C' |
| GRANT SELECT ON `playground`.* TO 'asdf'@'localhost' WITH GRANT OPTION |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
root@localhost:playground > revoke grant option on playground.* from asdf@localhost;
Query OK, 0 rows affected (0.00 sec)
root@localhost:playground > show grants for asdf@localhost;
+-------------------------------------------------------------------------------------------------------------+
| Grants for asdf@localhost |
+-------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'asdf'@'localhost' IDENTIFIED BY PASSWORD '*7F0C90A004C46C64A0EB9DDDCE5DE0DC437A635C' |
| GRANT SELECT ON `playground`.* TO 'asdf'@'localhost' |
+-------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)Context
StackExchange Database Administrators Q#133821, answer score: 8
Revisions (0)
No revisions yet.