为什么“授予使用”是指“授权使用”?我第一次授予用户权限时创建的?

发布于 2024-08-19 07:58:09 字数 575 浏览 12 评论 0原文

当我注意到这一点时,我是 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ㄖ落Θ余辉 2024-08-26 07:58:09

正如您所说,在 MySQL 中 USAGE 与“无特权”同义。来自 MySQL 参考手册

USAGE 权限说明符代表“无权限”。它在全局级别与 GRANT 一起使用,以修改帐户属性,例如资源限制或 SSL 特征,而不影响现有帐户权限。

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:

The USAGE privilege specifier stands for "no privileges." It is used at the global level with GRANT to modify account attributes such as resource limits or SSL characteristics without affecting existing account privileges.

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, hence USAGE. 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 privileges ON *.*, they are granted USAGE ON *.* and their password hash is displayed there. This is often a side effect of a CREATE USER statement. When a user is created in that way, they initially have no privileges so they are merely granted USAGE.

假扮的天使 2024-08-26 07:58:09

我试图找到 GRANT USAGE on *.* TO 的含义,并在这里找到。我可以澄清一下,当您使用以下命令(CREATE创建用户时,将授予GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password >):

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'; 

当您使用GRANT授予权限时,新的权限将添加在其之上。

I was trying to find the meaning of GRANT USAGE on *.* TO and found here. I can clarify that GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password will be granted when you create the user with the following command (CREATE):

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password'; 

When you grant privilege with GRANT, new privilege s will be added on top of it.

无法言说的痛 2024-08-26 07:58:09

另外,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 yes USAGE is used to modify an account by granting simple resource limiters such as MAX_QUERIES_PER_HOUR, again this can be specified by also
using the WITH clause, in conjuction with GRANT USAGE(no privileges added) or GRANT ALL, you can also specify GRANT USAGE at the global level, database level, table level,etc....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文