如何授予整个子网的MySQL远程访问权限? [英] How to grant remote access to MySQL for a whole subnet?

查看:173
本文介绍了如何授予整个子网的MySQL远程访问权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下代码轻松地授予对一个IP的访问权限:

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;

但是我需要允许整个子网192.168.1.*远程访问数据库.

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

我该怎么做?

推荐答案

考虑查看并赞成

Consider looking at and upvoting Malvineous's answer on this page. Netmasks are a much more elegant solution.

只需在IP地址中使用百分号作为通配符即可.

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

来自 http://dev.mysql.com/doc/refman /5.1/en/grant.html

您可以在主机名中指定通配符.例如,user_name@'%.example.com'适用于user_name域中任何主机的user_nameuser_name@'192.168.1.%'适用于192.168.1 C类子网中任何主机的user_name.

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

这篇关于如何授予整个子网的MySQL远程访问权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆