Reputation: 4080
I'm learning how to create a user with a query. I found the following to be working on my localhost, but I'm not sure what the percent sign (%) means. It creates the user test_user
with %
as the host "Host", as displayed in phpMyAdmin, instead of a localhost
Host like for other users I have.
CREATE USER 'test_user'@'%' IDENTIFIED BY 'password';
Also, what would I be doing wrong in assigning privileges to this user?
This doens't work:
GRANT SELECT, UPDATE ON test_db.* TO 'test_user'@'localhost';
This works:
GRANT SELECT, UPDATE ON *.* TO 'test_user'@'localhost';
Upvotes: 1
Views: 243
Reputation: 13866
As far as I know % sign is a wildcard in SQL. So it means that the host for test_user is able to connect from any host/ip.
Upvotes: 1
Reputation: 80629
%
is MySQL wildcard, similar to *
in regexes and several other places.
Here, it decides that the test_user
can connect from any IP.
Upvotes: 1
Reputation: 1135
The %
character in MySQL is a wildcard character for strings. Having a %
as the hostname for your user allows them to connect from any host.
You can find more info about it here: MySQL account name reference
Upvotes: 2