MySQL 服务器拒绝通过 SSH 隧道的本地连接 [英] MySQL Server Refusing Local Connections Over SSH Tunnel

查看:51
本文介绍了MySQL 服务器拒绝通过 SSH 隧道的本地连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 MySQL 和 Cygwin 的远程 Windows 服务器(启用远程 SSH 连接).当我从 Workbench 的本地实例(即使用 Workbench 处理隧道)连接时,以 root 身份通过 SSH 连接到远程数据库没有问题.

I have a remote Windows server with MySQL and Cygwin (enabling remote SSH connections). When I connect from a local instance of Workbench (i.e. with Workbench handling the tunnel), via SSH as root, I have no problem connecting to the remote database.

我需要设置自己的隧道,因为我有另一个需要访问 MySQL 的应用程序.我选择使用 Putty,但只取得了部分成功.

I have a need to set up my own tunnel because I have another app that needs MySQL access. I chose to use Putty, and had only partial success.

我可以通过我的隧道 localhost:3307 连接(使用 Workbench 作为测试客户端),我已将其转发到 myremoteserver.no-ip.com:3306,仅当我将远程 root 用户设置为接受连接时来自所有主机 (%),和/或服务器的实际 IP.

I can connect (using Workbench as a test client) through my tunnel, localhost:3307, which I have forwarded to myremoteserver.no-ip.com:3306, ONLY if I have the remote root user there set to accept connections from all hosts (%), AND/OR the actual IP of the server.

如果我将 root 限制为 127.0.0.1(应该如此),我会收到错误 Host xxxx is not allowed to connect to this MySQL server 其中 xxxx 是远程服务器的实际地址!

If I restrict root to 127.0.0.1 (as it should be) I get the error Host x.x.x.x is not allowed to connect to this MySQL server where x.x.x.x is the actual address of the remote server!

不知何故,使用 Putty 建立隧道并没有将我显示为本地连接.而是作为远程连接,即使远程IP是远程服务器的IP

Somehow, using Putty to make the tunnel isn't presenting me as a local connection. But instead as a remote connection, even though the remote IP is the IP of the remote server

我的问题:如何设置 Putty 以模仿 Workbench 成功建立隧道连接的方式?

My Question: How can I set up putty to mimic the way Workbench successfully makes tunnel connections?

注意:我与远程 IP 的所有连接都是通过无 IP 地址进行的.这在 Workbench 打开隧道时起作用.我的服务器也在 AWS EC2 生态系统中运行.

Note: All my connections to the remote IP are via a no-ip address. This works when Workbench opens the tunnel. Also my server is run within the AWS EC2 ecosystem.

我当前的 Putty 连接是到 no-ip 地址,隧道设置为 Source:3307, Destination: myremoteserver.no-ip.com:3306, Local 和 Auto.

My current Putty connection is to the no-ip address and tunneling settings are Source:3307, Destination: myremoteserver.no-ip.com:3306, Local and Auto.

我也尝试过将 127.0.0.1:3306 作为 Putty 隧道设置中的目标地址并得到相同的结果.

I have also tried 127.0.0.1:3306 as the destination address in the Putty tunnel settings and got the same result.

推荐答案

我当前的 Putty 连接是到 no-ip 地址和隧道设置是来源:3307,目的地:myremoteserver.no-ip.com:3306,本地和自动.

My current Putty connection is to the no-ip address and tunneling settings are Source:3307, Destination: myremoteserver.no-ip.com:3306, Local and Auto.

你想限制 mysql 的远程实例只接受本地主机接口上的连接,所以你的隧道应该转发到远程主机的本地主机接口而不是它的网络接口.将隧道的目标地址更改为 127.0.0.1 而不是服务器的名称.

You want to restrict the remote instance of mysql to only accept connections on the localhost interface, so your tunnel should forward to the remote host's localhost interface instead of its network interface. Change the tunnel's destination address to 127.0.0.1 instead of the server's name.

这篇关于MySQL 服务器拒绝通过 SSH 隧道的本地连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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