连接到 OpenShift 服务
Connecting to OpenShift Service
我最近才接触到 OpenShift,所以请多多包涵。我已经在我的域上设置了一个 MySQL 数据库,并且能够从 phpMyAdmin 页面添加和删除项目。我现在想在我的机器上做一个应用程序,并且只能在我的机器上连接到数据库,并且能够有 read/write 访问权限。我已经为这个用户设置了权限,并制作了一个 C# 表单以供编码。我已经执行了以下操作:
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)
您应该使用应用程序 url 而不是 IP 地址,您列出的每个地址都是 loopback interface,并不代表您的应用程序 url。
尝试使用 http://yourappdomain.rhcloud.com:3306
我最近才接触到 OpenShift,所以请多多包涵。我已经在我的域上设置了一个 MySQL 数据库,并且能够从 phpMyAdmin 页面添加和删除项目。我现在想在我的机器上做一个应用程序,并且只能在我的机器上连接到数据库,并且能够有 read/write 访问权限。我已经为这个用户设置了权限,并制作了一个 C# 表单以供编码。我已经执行了以下操作:
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)
您应该使用应用程序 url 而不是 IP 地址,您列出的每个地址都是 loopback interface,并不代表您的应用程序 url。
尝试使用 http://yourappdomain.rhcloud.com:3306