Reputation: 33
I am aware of the command
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
That will allow remote connections from the ip 1.2.3.4
, but what if I wanted to allow connections from both 1.2.3.4
and 5.6.7.8
?
Would it look like this?
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4, 5.6.7.8' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Or is this not allowed?
Upvotes: 1
Views: 15028
Reputation: 59
With MySQL wildcards. instead of using limited numbers you can implement a wildcard. this can be done by adding '%' instead of the numbers.
Upvotes: 0
Reputation: 118
You can run above command many times to GRANT access from multiple IPs.
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'5.6.7.8' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
to all ips
mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
Upvotes: 10