MySQL Variables bind_address 数据库 参数变量解释及正确配置使用

本站中文解释

bind_address 是 MySQL 中的一个参数变量,表示 MySQL 允许监听的服务器地址。

设置 bind_address:

1. 打开MySQL服务器的配置文件 my.cnf;

2. 在 [mysqld] 选项卡中添加或修改 bind_address 字段,例如:

bind_address = 0.0.0.0

3. 保存并重启MySQL服务器即可生效。

官方英文解释

bind_address

Command-Line Format --bind-address=addr
System Variable bind_address
Scope Global
Dynamic No
Type String
Default Value *

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. To specify an address, set
bind_address=addr
at server startup, where addr is an
IPv4 or IPv6 address or a host name. If
addr is a host name, the server
resolves the name to an IP address and binds to that address.
If a host name resolves to multiple IP addresses, the server
uses the first IPv4 address if there are any, or the first
IPv6 address otherwise.

The server treats different types of addresses as follows:

  • 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 address is 0.0.0.0, the server
    accepts TCP/IP connections on all server host IPv4
    interfaces.

  • If the address is ::, the server
    accepts TCP/IP connections on all server host IPv4 and
    IPv6 interfaces.

  • If the address is an IPv4-mapped address, the server
    accepts TCP/IP connections for that address, in either
    IPv4 or IPv6 format. For example, if the server is bound
    to ::ffff:127.0.0.1, clients can
    connect using --host=127.0.0.1 or
    --host=::ffff:127.0.0.1.

  • If the address is a regular IPv4 or IPv6
    address (such as 127.0.0.1 or
    ::1), the server accepts TCP/IP
    connections only for that IPv4 or IPv6 address.

If binding to the address fails, the server produces an error
and does not start.

If you intend to bind the server to a specific address, be
sure that the mysql.user system table
contains an account with administrative privileges that you
can use to connect to that address. Otherwise, you cannot shut
down the server. For example, if you bind the server to
*, you can connect to it using all existing
accounts. But if you bind the server to
::1, it accepts connections only on that
address. In that case, first make sure that the
'root'@'::1' account is present in the
mysql.user table so you can still connect
to the server to shut it down.

This variable has no effect for the embedded server
(libmysqld) and is not visible within the
embedded server.


数据运维技术 » MySQL Variables bind_address 数据库 参数变量解释及正确配置使用