1

In MySQL, I created a user and granted all privileges to the user. I even granted proxy to user.

CREATE USER IF NOT EXISTS 'testuser'@'localhost' IDENTIFIED BY 'testpass';
GRANT ALL PRIVILEGES ON *.* TO 'testuser'@'localhost' WITH GRANT OPTION;
GRANT PROXY ON ''@'' TO 'testuser'@'localhost' WITH GRANT OPTION;

Now if I drop the user, will the user's privileges and proxy be revoked? Or do I need to manually revoke the user's privileges and proxy before I drop the user?

DROP USER IF EXISTS 'testuser'@'localhost';
5
  • 2
    Just test it? It'll take you 1 minute.
    – Philᵀᴹ
    Commented Dec 21, 2016 at 8:40
  • Yeah, I should have tested it. It seems dropping user revokes privileges and proxy.
    – kimbaudi
    Commented Dec 21, 2016 at 8:46
  • You could query the mysql.proxies_priv table to see if the entry for the user is removed.
    – John K. N.
    Commented Dec 21, 2016 at 8:56
  • I just ended up doing SHOW GRANTS FOR 'testuser'@'localhost' after dropping the user and there was no results, which means grants are automatically revoked.
    – kimbaudi
    Commented Dec 21, 2016 at 9:05
  • it store results in user tables within mysql if assigned on objects and if assigned on database level one entry in db table, once you drop the user both entries get deleted. Commented Dec 21, 2016 at 10:44

1 Answer 1

3

The DROP USER statement removes one or more MySQL accounts and their privileges. It removes privilege rows for the account from all grant tables.

see http://dev.mysql.com/doc/refman/5.7/en/drop-user.html

PROXY is a GRANT privilege so the proxy privilege should be deleted also.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.