skystar7 skystar7 - 1 year ago 228
SQL Question

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

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@'' IDENTIFIED BY 'your-root-password';

But i need to allow the whole subnet 192.168.1.* to access the database remotely.

How can i do that?

Answer Source

Simply use a percent sign as a wildcard in the IP address.


You can specify wildcards in the host name. For example, user_name@'' applies to user_name for any host in the domain, and user_name@'192.168.1.%' applies to user_name for any host in the 192.168.1 class C subnet.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download