如何从C#连接到MySQL通过SSH [英] How to connect to mysql from C# over SSH

查看:176
本文介绍了如何从C#连接到MySQL通过SSH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何可以连接到MySQL数据库槽C#,

How can I connect to a mysql database trough C#,

这是我的连接字符串现在:

This is my connection string now:

connectionString="server=localhost;port=3306;user id=root;Password=*****;database=Data" providerName="MySql.Data.MySqlClient"

如何把SSH字符串以这种形式,因为它需要是这样的:

How to put SSH string in this form as it needs to be something like:

SSH主机名,SSH用户名,SSH密码,MySQL主机,MySQL用户名,Mysql的密码,端口

SSH Hostname, SSH Username, SSH password, Mysql Hostname, Mysql Username, Mysql Password, Port

推荐答案

我不认为MySQL和的了MySqlClient支持这样的事情。连接字符串是专门针对数据库。您将需要一个SSH客户端首先向SSH服务器进行连接,然后找到一种方法来路由通过该隧道的SQL连接。

I don't think MySql and the MySqlClient support such a thing. The connection string is specifically for the database. You will need an SSH client to connect first to the SSH server and then find a way to route the Sql connection over that tunnel.

<一个href="http://www.howtogeek.com/howto/ubuntu/access-your-mysql-server-remotely-over-ssh/">http://www.howtogeek.com/howto/ubuntu/access-your-mysql-server-remotely-over-ssh/

我不认为这是一个微软的.Net库处理SSH连接,但没有对code Plex的,可以帮助一个开源项目。

I don't think there is a Microsoft .Net library for handling SSH connections but there is an open source project on Code Plex that might help.

HTTP://sshnet.$c$cplex.com/

这篇关于如何从C#连接到MySQL通过SSH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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