Home > Database > Mysql Tutorial > 怎样才能指定MySQL只监听某个特定的地址_MySQL

怎样才能指定MySQL只监听某个特定的地址_MySQL

WBOY
Release: 2016-06-01 14:04:44
Original
845 people have browsed it
 

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

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

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

 

<ccid_code></ccid_code>$bindir/mysqld_safe --datadir=$datadir
 --pid-file=$pid_file &
Copy after login

 

修改成:

 

<ccid_code></ccid_code>$bindir/mysqld_safe --datadir=$datadir
--pid-file=$pid_file --bind-address=127.0.0.1 &
Copy after login

 

重起MySQL:

 

<ccid_code></ccid_code>/etc/init.d/mysql restart
Copy after login

最后netstat -l确认一下:

 

<ccid_code></ccid_code>tcp 0 0 localhost:mysql *:* LISTEN
Copy after login

OK。

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template