我正在尝试将我的 C# 应用程序与 openshift 数据库连接。但我得到了这个例外conn.Open()
Eccezione => MySql.Data.MySqlClient.MySqlException (0x80004005): Unable to connect to any of the specified MySQL hosts.
in MySql.Data.MySqlClient.NativeDriver.Open()
in MySql.Data.MySqlClient.Driver.Open()
in MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
in MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
in MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
in MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
in MySql.Data.MySqlClient.MySqlPool.GetConnection()
in MySql.Data.MySqlClient.MySqlConnection.Open()
这是我的方法:
public void connect()
{
string connStr = @"Server=test-lound.rhcloud.com;Port=3306;Database=test;Uid=XXXX;Pwd=YYYY;";
MySqlConnection conn = new MySqlConnection(connStr);
try
{
Console.WriteLine("Connecting to MySQL...");
conn.Open();
Console.WriteLine("Connection successfull !");
conn.Close();
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine("Eccezione => " + ex.ToString());
}
Console.WriteLine("Done.");
}
我做错了什么?是否可以通过 C# 客户端应用程序与 openshift 数据库建立连接?
Edit:
我找到了这个文件here https://forums.openshift.com/connect-a-mysql-client-sqlyog-to-mysql-5-on-openshift描述了 SSH 隧道要求。也许这是必要的。
好吧,我终于端到端地工作了,但它是通过 ssh 隧道的 Mysql Workbench。这是 OpenShift 的一项要求,因为它是位于 IaaS AWS (Amazon EC2) 之上的 PaaS。所以对于开发者来说这不是问题。对于最终用户来说,如果没有 ssh-rsa 公钥对,它就无法工作,正如我所见。
一路上有一些不错的链接:A site for fast and easy 2048bit ssh-rsakey gen http://generator.my-addr.com/generate_ssh_public_rsa_key-private_rsa_key-ssh_pair_online_tool.php. A doc https://developers.openshift.com/en/managing-remote-connection.html对于腻子和腻子根。这doc https://forums.openshift.com/connecting-to-openshift-mysql-using-workbench用于隧道设置(关键);看看什么dgreen wrote.
解决方案是为应用程序提供密钥对,并针对隧道相应地调整 C#,或者使用 AWS EC2 IaaS,这很简单。 AWS 有一个免费套餐 https://aws.amazon.com/free/一年。我可以轻松设置它,因为那是我最熟悉的地方。但我必须说我确实喜欢 Openshift 及其 PHP 前端。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)