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

Viewed 154008

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
4 Answers

I'm running into the same thing, and regardless of the grants I do, the user still doesn't have access to the databases that I specify via php. When I show grants for the user, this is what I get.

GRANT USAGE ON *.* TO 'btmeddbusr'@'localhost'
GRANT ALL PRIVILEGES ON `btmeddb`.* TO 'btmeddbusr'@'localhost'
GRANT ALL PRIVILEGES ON `BigTymeDB`.* TO 'btmeddbusr'@'localhost'

It works fine when I use root user, but I would prefer not to.

Related