Why is a "GRANT USAGE" created the first time I grant a user privileges?

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
157383 次浏览

As you said, in MySQL USAGE is synonymous with "no privileges". From the MySQL 参考手册:

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

USAGE是一种告诉 MySQL 某个帐户存在而不向该帐户授予任何实际特权的方法。它们只有对 MySQL 服务器 使用的权限,因此 USAGE。它对应于 `mysql`.`user`表中没有设置特权的行。

IDENTIFIED BY子句指示为该用户设置了密码。我们怎么知道一个用户就是他们所说的那个人?他们自己通过发送正确的密码为他们的帐户 确认身份

用户密码是不绑定到特定数据库或表的全局级帐户属性之一。它也存在于 `mysql`.`user`表中。如果用户没有任何其他特权 ON *.*,则授予他们 USAGE ON *.*,并在那里显示他们的密码散列。这通常是 CREATE USER语句的副作用。当以这种方式创建用户时,它们最初没有特权,因此只被授予 USAGE

另外 mysql 密码在不使用 IDENTIFIED BY子句时,可能是空值,如果非空,则可能对它们进行加密。但是,是的,USAGE通过授予简单的资源限制器(如 MAX_QUERIES_PER_HOUR)来修改帐户,同样,这也可以由 使用 WAS 子句,结合 GRANT USAGE(没有添加特权)或 GRANT ALL,您还可以在全局级别、数据库级别、表级别等指定 GRANT USAGE..。

我试图找到 GRANT USAGE on *.* TO的意义,并在这里发现。我可以澄清,GRANT USAGE on *.* TO user IDENTIFIED BY PASSWORD password将授予当您 创造的用户与以下命令(CREATE) :

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

当您使用 GRANTGrant特权时,新的特权 s 将添加到其上。