【问题标题】:Connecting to MySQL through SSH tunnel and ForwardPrtLocal通过 SSH 隧道和 ForwardPrtLocal 连接 MySQL
【发布时间】:2018-07-05 12:27:07
【问题描述】:

我正在尝试连接到客户端服务器上的 MySQL 数据库。我遇到的问题是在本地机器上的 MySQL 运行时发生的。我的 Windows 服务尝试连接到我的 sqlç 客户端时出现错误

An attempt was made to access a socket in a way forbidden by its access permissions

似乎我们本地的 sql 正在使用 3306 端口并阻止它。如果我在我们的服务器上停止 MySQL 并运行 Windows 服务,那就没问题了。我怎样才能解决这个问题?

PasswordConnectionInfo connectionInfo = new PasswordConnectionInfo("########",####, "######", "#######");
connectionInfo.Timeout = TimeSpan.FromSeconds(500);
SshClient client = new SshClient(connectionInfo);
client.Connect();
ForwardedPortLocal portFwld = new ForwardedPortLocal("127.0.0.1",3306,"127.0.0.1", 3306); client.AddForwardedPort(portFwld);portFwld.Start();
// using Renci.sshNet 
DBConnect connection = new DBConnect(portFwld);

【问题讨论】:

  • 下次请用更好的英文和格式写出您的问题。

标签: mysql windows-services


【解决方案1】:

您可以在本地 3307 端口上转发客户端 3306 端口。 然后用3307连接mysql。

您可以使用 putty 进行测试:

Putty example here

试试这个:var port = new ForwardedPortLocal("localhost", 3307, "your remote server", 3306);

【讨论】:

    猜你喜欢
    • 2018-10-06
    • 2012-06-19
    • 2022-01-03
    • 2014-03-21
    • 2014-09-17
    • 1970-01-01
    • 2021-02-15
    相关资源
    最近更新 更多