简体   繁体   English

MySQL 使用绑定地址远程访问

[英]MySQL remote access using bind-address

I am studying MySQL and trying to understand how bind-address works on version 8. Whenever I put bind-address= 127.0.0.1 / (local machine ip) and then:我正在研究 MySQL 并试图了解 bind-address 如何在版本 8 上工作。每当我输入 bind-address= 127.0.0.1 / (本地机器 ip) 然后:

CREATE USER 'test'@'other_machine_ip' IDENTIFIED WITH mysql_native_password BY 'xxxxxx';
GRANT ALL ON *.* TO 'test'@'other_machine_ip';

Other machine can connect remotely like this, but when I do bind-address=other_machine_ip the mysql doesn't start.其他机器可以像这样远程连接,但是当我执行 bind-address=other_machine_ip 时,mysql 无法启动。

can anyone explain?谁能解释一下?

127.0.0.1 is a special IP Address owned by ALL IPv4 machines they use to talk to themselves , so it always refers to the local machine. 127.0.0.1是一个特殊的 IP 地址,由他们用来与自己通信的所有IPv4 机器拥有,所以它总是指本地机器。

If you want machine A to talk to machine B then the IP Address you give to machine A must be the IP Address of machine B .如果您希望机器A与机器B对话,那么您提供给机器A的 IP 地址必须是机器B的 IP 地址。 If you tell machine A to connect to 127.0.0.1 , it will try & connect to itself.如果您告诉机器A连接到127.0.0.1 ,它将尝试连接到自己。

The MySQL login you use from A will also need to be configured on B to be allowed to access the database from A , by setting up a password that allows this, eg您从A使用的 MySQL 登录也需要在B上进行配置,以允许从A访问数据库,方法是设置允许这样做的密码,例如

grant all privileges on ${DATABASE}.* to '${USERNAME}'@'${MACHINE-A}' identified by '${PASSWORD}'

(substitute as appropriate) (酌情替代)

You also need to be able to route between the two.您还需要能够在两者之间进行路由。 Check they can both ping each other.检查他们都可以互相ping

MySQL will also need to be listening on port 3306 , as well as a local unix socket, eg by adding port=3306 into the [mysqld] section of my.cnf on the server, and in the [client] section of my.cnf on the client. MySQL 还需要监听端口3306以及本地 unix 套接字,例如通过将port=3306添加到服务器上my.cnf[mysqld]部分和my.cnf[client]部分在客户端上。

NOTE: MySQL does NOT perform well over long distance or high latency links.注意: MySQL在长距离或高延迟链路上表现不佳。 You will probably experience unexpectedly poor performance.您可能会遇到意想不到的糟糕表现。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM