问题
I'm trying to connect my c# application with openshift database. But I get this exception on the 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()
this is my method:
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.");
}
what I doing wrong? Is possible establish a connection with a openshift database through c# client application?
Edit: I found this document here that describes an SSH tunnel requirement. Perhaps that is necessary.
回答1:
Alright, I finally worked it end-to-end but it is Mysql Workbench via ssh tunnel. It is a requirement for openshift as it is a PaaS sitting on top of IaaS AWS (Amazon EC2). So for the developer it is no problem. For the end-user, without a ssh-rsa public keypair, it won't work, as I see it.
A few good links to capture along the way: A site for quick and easy 2048bit ssh-rsa key gen. A doc for putty and puttygen. The doc for tunnel setup (critical); look what dgreen wrote.
A solution is to either supply a keypair with the app, and tweak your C# accordingly for the tunnel, or to go with AWS EC2 IaaS and it is a snap. AWS has a Free-tier for a year. I could set that up easily, as that is where I am most familiar. But I must say I do like Openshift and its PHP front end.
来源:https://stackoverflow.com/questions/31905849/connect-to-openshift-redhat-paas-mysql-instance