为什么“授予使用”是指“授权使用”?我第一次授予用户权限时创建的?
当我注意到这一点时,我是 DBMS 管理方面的新手,今晚正在设置一个新数据库(使用 MySQL)。第一次授予用户权限后,会创建另一个授权,看起来像
GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password
文档说 USAGE
权限意味着“无权限”,所以我推断授权是分层工作的,也许是用户必须对所有数据库拥有某种权限,所以这可以作为一个包罗万象的功能吗?
我也不明白为什么这一行有一个 IDENTIFIED BY
子句,而我创建的授权没有一个 IDENTIFIED BY
子句(主要是因为我不明白 IDENTIFIED BY
子句的目的是什么)。
编辑:很抱歉最初没有说明这一点,赠款是
GRANT ALL PRIVILEGES ON database.* TO admin_user
GRANT SELECT, INSERT, UPDATE, DELETE ON database.* TO user
I'm new to the admin side of DBMS and was setting up a new database tonight (using MySQL) when I noticed this. After granting a user a privilege for the first time, another grant is created that looks like
GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password
The documentation says that the USAGE
privilege means "no privileges," so I'm inferring thats grants work hierarchically and perhaps a user must have some kind of privilege for all databases, so this serves as a catch all?
I also dont understand why this line has an IDENTIFIED BY
clause in it when the grant I created does not have one (mostly because I dont understand what purpose the IDENTIFIED BY
clause serves).
Edit: Sorry for not stating this originally, the grants were
GRANT ALL PRIVILEGES ON database.* TO admin_user
GRANT SELECT, INSERT, UPDATE, DELETE ON database.* TO user
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如您所说,在 MySQL 中
USAGE
与“无特权”同义。来自 MySQL 参考手册:USAGE
是一种告诉 MySQL 帐户存在但不向该帐户授予任何实际权限的方法。他们仅具有使用 MySQL 服务器的权限,因此USAGE
。它对应于`mysql`.`user`
表中未设置权限的行。IDENTIFIED BY
子句指示为该用户设置密码。我们如何知道用户就是他们所说的那个人?他们通过发送正确的帐户密码来识别自己的身份。用户的密码是不依赖于特定数据库或表的全局级帐户属性之一。它还存在于
`mysql`.`user`
表中。如果用户没有任何其他权限ON *.*
,他们将被授予USAGE ON *.*
并且他们的密码哈希值会显示在那里。这通常是 CREATE USER 语句的副作用。当以这种方式创建用户时,他们最初没有任何权限,因此仅被授予USAGE
。As you said, in MySQL
USAGE
is synonymous with "no privileges". From the MySQL Reference Manual:USAGE
is a way to tell MySQL that an account exists without conferring any real privileges to that account. They merely have permission to use the MySQL server, henceUSAGE
. It corresponds to a row in the`mysql`.`user`
table with no privileges set.The
IDENTIFIED BY
clause indicates that a password is set for that user. How do we know a user is who they say they are? They identify themselves by sending the correct password for their account.A user's password is one of those global level account attributes that isn't tied to a specific database or table. It also lives in the
`mysql`.`user`
table. If the user does not have any other privilegesON *.*
, they are grantedUSAGE ON *.*
and their password hash is displayed there. This is often a side effect of aCREATE USER
statement. When a user is created in that way, they initially have no privileges so they are merely grantedUSAGE
.我试图找到
GRANT USAGE on *.* TO
的含义,并在这里找到。我可以澄清一下,当您使用以下命令(CREATE创建用户时,将授予
GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password
>):当您使用
GRANT
授予权限时,新的权限将添加在其之上。I was trying to find the meaning of
GRANT USAGE on *.* TO
and found here. I can clarify thatGRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password
will be granted when you create the user with the following command (CREATE
):When you grant privilege with
GRANT
, new privilege s will be added on top of it.另外,mysql密码在不使用
IDENTIFIED BY
子句时,可能为空值,如果非空,则它们可能被加密。但是,USAGE
用于通过授予简单的资源限制器(例如MAX_QUERIES_PER_HOUR
)来修改帐户,这也可以通过以下方式指定使用WITH子句,与
GRANT USAGE
(不添加权限)或GRANT ALL
结合使用,您还可以在全局级别指定GRANT USAGE
,数据库级别,表级别等等......In addition mysql passwords when not using the
IDENTIFIED BY
clause, may be blank values, if non-blank, they may be encrypted. But yesUSAGE
is used to modify an account by granting simple resource limiters such asMAX_QUERIES_PER_HOUR
, again this can be specified by alsousing the WITH clause, in conjuction with
GRANT USAGE
(no privileges added) orGRANT ALL
, you can also specifyGRANT USAGE
at the global level, database level, table level,etc....