成功将客户端连接到MySQL服务器 [英] Successfully connect Client to MySQL server

查看:92
本文介绍了成功将客户端连接到MySQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到很多有关在拒绝或失败连接时如何将客户端连接到MySQL服务器的查询.为了将来简化响应,我将在IP和MySQL级别发布一个简单的连接需求图.必要时,我将在每个部分添加说明.

I see a lot of queries about how to connect a client to a MySQL server when the connection is refused or unsuccessful. In the interest of simplifying responses in the future, I am going to post a simple diagram of connection needs at the IP and MySQL Level. I will add description to each section when need be.

推荐答案

要从客户端计算机连接到MySQL数据库,数据必须遍历多达5个级别的验证.在一般情况下,客户端和服务器不在同一网络上,并且未使用安全连接:

To connect from a client machine to a MySQL DB, the data has to traverse up to 5 levels of validation. Here's a general case where the client and server are not on the same network and a secure connection is not used:

首先请确保MySQL使用的bind-addresslocalhost不同,因此它使用的是接口,而不仅仅是本地连接.

First make sure MySQL is using a bind-address that is different from localhost so it uses an interface and not just local connections.

在每个级别,防火墙规则/权限都必须允许连接通过.请注意,一台机器内部的IP可能经常与外部的IP不同.基本原理是:

At each level, the firewall rules/permissions have to allow the connection to go through. Note that a machine can and often has a different IP internally than externally. The basic principle is:

必须允许客户端外部 IP通过所有级别连接到数据库内部 IP.

The Client external IP has to be allowed to connect to the DB internal IP, through all the levels.

大多数情况下,防火墙配置正确.最后一块通常缺少外部用户对DB的MySQL服务器GRANT许可.最后一种语法是:

Most of the time, the firewalls are properly configured. The last piece often missing the the MySQL server GRANTing permission to the DB for the external user. The last syntax is:

MySQL Grant语法

通常采用以下形式:

GRANT ALL ON <DB>.* TO '<external_user>'@'<external_ip>' IDENTIFIED BY 'external_password';

这篇关于成功将客户端连接到MySQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆