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

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

问题描述

如何通过C#连接到mysql数据库,

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

这是我的连接字符串:

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.

http://www.howtogeek.com/howto/ubuntu/access-your-mysql-server-remotely-over-ssh/

认为有一个Microsoft .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.codeplex.com/

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

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