简体   繁体   English

在openshift上连接到mysql服务器时出错

[英]Error connecting to mysql server on openshift

Im trying to connect to a mysql database running on openshift. 我试图连接到在openshift上运行的mysql数据库。 The computer I have used is running win 10. Below is my C# code snippet of what im trying to do. 我使用的计算机正在运行win10。以下是我尝试执行的操作的C#代码段。 The server address, password, and username have been blanked out. 服务器地址,密码和用户名已被清空。

  string connStr = @"Server=xxxxxxx.rhcloud.com:3306;Database=hurnhusms;Uid=XXX;password=XXX;";
        SqlConnection conn = new SqlConnection(connStr);
        try
        {
            Console.WriteLine("Connecting to MySQL...");
            conn.Open();
            Console.WriteLine("Connection successfull !");
            conn.Close();
            Console.ReadLine();
        }
        catch (Exception ex)
        { 
            Console.WriteLine("error => " + ex.ToString()); 
        }
        Console.ReadLine();

when I run the application all I get is: 当我运行该应用程序时,我得到的是:

System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. System.Data.SqlClient.SqlException(0x80131904):建立与SQL Server的连接时发生与网络相关或特定于实例的错误。 The server was not found or was not accessible. 服务器未找到或无法访问。 Verify that the instance name is correct and that SQL Server is configured to allow remote connections. 验证实例名称正确,并且已将SQL Server配置为允许远程连接。 i have also ran rhc port-forward , i have also pinged the mysql port on the site and it is open. 我还运行了rhc port-forward,我也对站点上的mysql端口进行了ping操作,它是开放的。

Any help would be appreciate. 任何帮助将不胜感激。

Okay what I figured out is that I need to execute the rhc port-forward and then keep that window open (not terminate that command). 好的,我发现我需要执行rhc port-forward,然后保持该窗口打开(而不是终止该命令)。 I didn't realize that window need to stay open. 我没有意识到窗户需要保持打开状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM