I can easily grant access to one IP using this code:
$ mysql -u root -p Enter password: mysql> use mysql mysql> GRANT ALL ON *.* to root@'192.168.1.4' IDENTIFIED BY 'your-root-password'; mysql> FLUSH PRIVILEGES;
But i need to allow the whole subnet 192.168.1.* to access the database remotely.
How can i do that?
To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';
To do so, you need to edit the MySQL configuration file and add or change the value of the bind-address option. You can set a single IP address and IP ranges. If the address is 0.0. 0.0 , the MySQL server accepts connections on all host IPv4 interfaces.
It looks like you can also use a netmask, e.g.
GRANT ... TO 'user'@'192.168.0.0/255.255.255.0' IDENTIFIED BY ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With