user784637 user784637 - 5 months ago 27
MySQL Question

Is there a way to GRANT ALL PRIVILEGES to the same user from multiple LAN addresses in a single command?

I'm using the following command

GRANT ALL PRIVILEGES ON *.* TO 'user'@'ip'
IDENTIFIED BY 'password'
WITH GRANT OPTION;


To grant all privileges to a user. Is there a way I can make the ip a wildcard like
192.168.1.*
so that I don't need to manually add each LAN ip I want give the user access to connect from?

Answer

Yes, use % in an address.

GRANT ALL PRIVILEGES ON *.* TO 'user'@'192.168.1.%' 
IDENTIFIED BY 'password' 
WITH GRANT OPTION;

Or you can use less restrictive host name and allow user to connect from everywhere.

GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' 
IDENTIFIED BY 'password' 
WITH GRANT OPTION;
Comments