MySQL数据库只监听某个特定地址的方法

问:怎样才能指定MySQL只监听某个特定地址?

答:比较常见的办法是,在my.cnf之mysqld节,添加bind-address=127.0.0.1。但是也有人按照下面的办法来做。

为了数据的安全,可以考虑让MySQL只守候在127.0.0.1上,这样从Internet上就无法直接访问数据库了。修改/etc/init.d/mysql文件,在start部分找到类似下面这行:

$bindir/mysqld_safe --datadir=$datadir

--pid-file=$pid_file &

修改成:

$bindir/mysqld_safe --datadir=$datadir

--pid-file=$pid_file --bind-address=127.0.0.1 &

重起MySQL:

/etc/init.d/mysql restart

最后netstat -l确认一下:

tcp 0 0 localhost:mysql *:* LISTEN

通过上文中介绍的方法就能够实现MySQL数据库操作过程中只监听某个特定地址,您学会了吗?


网页名称:MySQL数据库只监听某个特定地址的方法
分享URL:http://www.gydahua.com/article/dhjpigh.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流