Revoke all privileges for all users on a MySQL DB

前端 未结 4 685
无人共我
无人共我 2020-12-15 06:29

From: http://dev.mysql.com/doc/refman/5.0/en/drop-database.html

...when a database is dropped, user privileges on the database are not automatically d

相关标签:
4条回答
  • 2020-12-15 07:18

    You can revoke all privileges for a specific user with this syntax:

    REVOKE ALL PRIVILEGES, GRANT OPTION FROM user [, user] ...
    FLUSH PRIVILEGES;
    

    which drops all global, database, table, column, and routine privileges for the named user or users

    Not sure if there's a way to do this for all users at once, though.

    0 讨论(0)
  • 2020-12-15 07:22
    REVOKE ALL PRIVILEGES ON *.* FROM '<user_name>'@'localhost';
    REVOKE ALL PRIVILEGES ON *.* FROM '<user_name>'@'%';
    

    Eg.:

    REVOKE ALL PRIVILEGES ON *.* FROM 'jeffrey'@'localhost';
    REVOKE ALL PRIVILEGES ON *.* FROM 'jeffrey'@'%';
    
    0 讨论(0)
  • 2020-12-15 07:33
    REVOKE ALL PRIVILEGES FROM '%'@'%';
    

    The above could be dangerous as i suppose it will delete all the privileges from all the users including root

    Modify it to:

    REVOKE ALL PRIVILEGES FROM 'user'@'localhost';
    

    or

    REVOKE ALL PRIVILEGES FROM 'user'@'%';
    

    before execute

    0 讨论(0)
  • 2020-12-15 07:33

    I suppose you can do:

    REVOKE ALL PRIVILEGES FROM '%'@'%';
    FLUSH PRIVILEGES;
    

    (Don't modify MySQL tables directly)

    0 讨论(0)
提交回复
热议问题