2016-04-26 69 views
0

我剛剛進入OpenShift,請耐心等待。我在我的域中設置了一個MySQL數據庫,並且能夠從phpMyAdmin頁面添加和刪除項目。我現在想在我的機器上創建一個應用程序,並且只在我的機器上連接到數據庫,並且能夠具有讀/寫訪問權限。我已經爲這個用戶設置了一個權限集,併爲C#編寫了一個表單。我已經執行了以下內容:連接到OpenShift服務

rhc port-forward --app <my application name> 

事後,我收到如下:

W:\>rhc port-forward --app <my application name> 
DL is deprecated, please use Fiddle 
Checking available ports ... done 
Forwarding ports ... 
Only one usage of each socket address (protocol/network address/port) is 
normally permitted. - bind(2) while forwarding port 8080. Trying local port 8081 
To connect to a service running on OpenShift, use the Local address 
Service Local    OpenShift 
httpd 127.0.0.1:8080 => 127.3.223.1:8080 
httpd 127.0.0.1:8081 => 127.3.223.3:8080 
mysql 127.0.0.1:3306 => 127.3.223.2:3306 
Press CTRL-C to terminate port forwarding 

因此,當我重新回到C#,我有下面的代碼行:

conn = new SqlConnection("user id="+tbUser.Text+";password="+tbPass.Text+";server=127.0.0.1:3306;database=<my application name>"); 
conn.Open(); 

但我得到.Open()函數的錯誤,說它找不到服務器或數據庫。我對正在發生的事情不知所措。

編輯:我想我還不如添加如果在所有有用的錯誤消息:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll 
Additional information: A network-related or instance-specific error occurred while establishing a connection to 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. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 

回答

2

您應該使用,而不是IP地址的應用程序URL,你列出的每個地址是loopback interface,不代表您的應用程序網址。

嘗試使用http://yourappdomain.rhcloud.com:3306