xiankai
xiankai

Reputation: 2781

The difference between MySQL wildcards for granting permissions

What is the difference between *, %, Any in the username/host fields when granting permissions to a user, and how would the combination of them differ?

For example:

GRANT ALL PRIVILEGES ON db.* TO '*'@'Any';

would this be the same as

GRANT ALL PRIVILEGES ON db.* TO 'Any'@'%';

EDIT: The Any field I was thinking of comes from phpMyAdmin. Perhaps it means something different? I have pasted a screenshot below to illustrate what I mean.

User permissions in phpMyAdmin

Upvotes: 0

Views: 124

Answers (1)

Joni
Joni

Reputation: 111249

The word "any" has no special meaning.

MySQL does not support wildcards in the user name, so the first example is illegal. To grant privileges to an anonymous user from a host called any use:

GRANT ALL PRIVILEGES ON db.* TO ''@'Any';

The second example is legal, but it grants privileges to a user called "any" who may connect from any host.

Upvotes: 1

Related Questions