Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant remote access to MySQL for a whole subnet?

Tags:

mysql

grant

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?

like image 288
skystar7 Avatar asked Jul 31 '12 14:07

skystar7


People also ask

How do I grant a full access in MySQL?

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';

How do I allow remote connections to MySQL from specific IPs only?

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.


1 Answers

It looks like you can also use a netmask, e.g.

GRANT ... TO 'user'@'192.168.0.0/255.255.255.0' IDENTIFIED BY ... 
like image 71
Malvineous Avatar answered Sep 19 '22 00:09

Malvineous