大网数据广告活动
服务器运维问答

MySQL: Is it a security risk to deactivate the setting "bind-address"?

· 52CE 我爱测

I have had a problem with a webapp connecting properly to a MySQL server and to solve it i tried to comment out the setting bind-address in the file my.ini . That seemed to solve the problem, however i was wondering if that is a …

问题原文

原帖链接 · flixe · CC BY-SA 4.0

I have had a problem with a webapp connecting properly to a MySQL server and to solve it i tried to comment out the setting bind-address in the file my.ini.

That seemed to solve the problem, however i was wondering if that is a nogo regarding security. Is that a proper setting for a production environment which of course is access restricted by user/password? And what is the difference between commenting it out and setting it to bind-address=0.0.0.0?

已采纳解答

原帖链接 · HBruijn · CC BY-SA 4.0

The impact of commenting out the setting depends on the value bind-address was set to before.

Commenting out a setting is the same as setting it to the default value. The manual will show you the default value: https://dev.mysql.com/doc/refman/8.0/en/server-options.html#option_mysqld_bind-address

bind-address
Default Value:
*

The manual also explains what that setting means and how it differs from using 0.0.0.0 :

If the address is *, the server accepts TCP/IP connections on all server host IPv4 interfaces, and, if the server host supports IPv6, on all IPv6 interfaces. Use this address to permit both IPv4 and IPv6 connections on all server interfaces. This value is the default. If the option specifies a list of multiple values, this value is not permitted.

If the address is 0.0.0.0, the server accepts TCP/IP connections on all server host IPv4 interfaces. If the option specifies a list of multiple values, this value is not permitted.

If your server is not secured with a firewall that restricts access to TCP port 3306 (the default port for MySQL) then using either * or 0.0.0.0 will accept incoming connections on all IPv4 addresses the server is configured with, as well as TCP connections on the loopback address 127.0.0.1/8 and * will additionally allow all incoming IPv6 traffic.

In general it is considered good security practice to only configure the minimum network access for services.
Both * and 0.0.0.0 are probably overly permissive in many situations, but for instance on a system that should allow remote MySQL access with a single interface/ip-address (i.e. 192.0.2.1) there would be no effective security difference between bind-address = 192.0.2.1 or bind-address = 0.0.0.0 or bind-address = *
On servers that don't need to allow remote MySQL access (the typical LAMP server) bind-address = ::ffff:127.0.0.1 would be recommended.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-02-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。