简体   繁体   中英

If a user is root in a database, am I right in thinking that user can't also have revoked permissions

If a user is root in a database, am I right in thinking that user can't also have revoked permissions. For Example, say the user is root and another root revokes their write privilege. Will the first root still be able to write to the database?

If the database is MySQL, then no.

root is just a name, but is often associated with a user that has full privileges, like in your case i assume. That means, there can be more users that have the same, or less privileges as your root user. This is also recommended because not every user needs every privilege.

And users can grant or revoke each others privileges if they can. Be careful because you can also revoke your own and lock yourself out.

Here is an example of a user that has full privileges on all db's, with grant and revoke:

mysql> CREATE USER 'admin'@'localhost' IDENTIFIED BY 'pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
mysql> CREATE USER 'admin'@'%' IDENTIFIED BY 'pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM