MySQL 绑定地址和MySQL服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3552680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 16:57:03  来源:igfitidea点击:

Bind address and MySQL server

mysqllinuxsecuritynetworkingubuntu

提问by Karthick

I came across the bind address while trying to configure the MySQL server. The details of why I want to configure the bind address is in the link below.

我在尝试配置 MySQL 服务器时遇到了绑定地址。我为什么要配置绑定地址的详细信息在下面的链接中。

Multiple hostnames and multiple privileges?

多个主机名和多个权限?

Now, I want to understand the purpose of the bind address. In the sense, is a binding address the address we assign to the machine that is hosting the MySQL server? 

现在,我想了解绑定地址的用途。从某种意义上说,绑定地址是我们分配给托管 MySQL 服务器的机器的地址吗? 

I have no clue. Would be really helpful if someone could explain me the purpose of it. Also, will assigning 0.0.0.0to the binding address create any security flaws/loop holes?

我没有线索。如果有人可以向我解释它的目的,那将非常有帮助。此外,分配0.0.0.0给绑定地址会产生任何安全漏洞/漏洞吗?

回答by Seth

The address you specify in bind tells MySQL where to listen. 0.0.0.0 is a special address, which means "bind to every available network".

你在 bind 中指定的地址告诉 MySQL 在哪里监听。0.0.0.0 是一个特殊地址,意思是“绑定到每个可用的网络”。

Only client software which is able to open a connection to the server using the same address that is specified in the 'bind' option will be allowed to connect.

只有能够使用 'bind' 选项中指定的相同地址打开到服务器的连接的客户端软件将被允许连接。

Some examples:

一些例子:

  • If MySQL binds to 127.0.0.1, then only software on the same computer will be able to connect (because 127.0.0.1 is always the local computer).
  • If MySQL binds to 192.168.0.2 (and the server computer's IP address is 192.168.0.2 and it's on a /24 subnet), then any computers on the same subnet (anything that starts with 192.168.0) will be able to connect.
  • If MySQL binds to 0.0.0.0, then any computer which is able to reach the server computer over the network will be able to connect.
  • 如果 MySQL 绑定到 127.0.0.1,那么只有同一台计算机上的软件才能连接(因为 127.0.0.1 始终是本地计算机)。
  • 如果 MySQL 绑定到 192.168.0.2(并且服务器计算机的 IP 地址是 192.168.0.2 并且它位于 /24 子网上),那么同一子网上的任何计算机(任何以 192.168.0 开头的)都将能够连接。
  • 如果 MySQL 绑定到 0.0.0.0,那么任何能够通过网络访问服务器计算机的计算机都可以连接。

These are all transport-level connections. Remote computers still need to qualify for application-level, which is to say they will still require the correct login credentials and host parameters from mysql.user.

这些都是传输级连接。远程计算机仍然需要获得应用程序级别的资格,也就是说它们仍然需要来自mysql.user.