msyql配置文件my.cnf中有选项bind-address=127.0.0.1,就是说mysql server监听的是本地发来的请求,如果开放任意主机都可以请求,则写为0.0.0.0,但是这样又不太安全。监听某ip,指定此ip地址即可,但是要保证mysql的user中有允许此ip访问,否则不能对数据库操作。那么是否可以在配置里只规定几个ip呢?
简单直接回答:不可能
请参考:#option_mysqld_bind-address
The MySQL server listens on a single network socket for TCP/IP connections. This socket is bound to a single address, but it is possible for an address to map onto multiple network interfaces. The default address is 0.0.0.0. To specify an address explicitly, use the ?bind-address=addr option at server startup, where addr is an IPv4 address or a host name. If addr is a host name, the server resolves the name to an IPv4 address and binds to that address. The server treats different types of addresses as follows:
If the address is 0.0.0.0, the server accepts TCP/IP connections on all server host IPv4 interfaces.
If the