OpenShift:如何从我的PC连接到postgresql

use*_*169 21 postgresql openshift

我有一个openshift应用程序,我刚刚在同一个盒式磁带上安装了一个postgresql数据库.

我安装了postgresql数据库,但现在我想从我的PC连接到数据库,所以我可以开始创建新表.

使用端口转发我找到了postgresql db的IP

127.3.146.2:5432

在我的webaccount下,我看到我的数据库:txxx用户:admixxx密码:xxxx

然后使用RazorSQl我尝试建立一个新的连接

因用户密码错误而不断出现.

如果我尝试使用本地IP连接,如127.0.0.1,那么我可以正常连接.

如何解决此问题,我要做的就是连接到此DB,以便我可以创建新表.

小智 31

如下所示,在运行"rhc port-forward $ appname"命令后,您需要连接到127.0.0.1的IP地址和旁边显示的端口以连接到您要访问的服务,例如PostgreSQL的.在下面的示例中,我将连接到127.0.0.1,端口5432.如果您已在postgresql端口上本地运行某些内容,它将选择另一个端口并将其显示在表中.但是连接将被转发到您的装备上的openshift装备和postgresql.

Corey-Red-Hat:~ cdaley$ rhc port-forward rt2
Checking available ports ... done
Forwarding ports ...

To connect to a service running on OpenShift, use the Local address

Service    Local               OpenShift
---------- -------------- ---- ---------------
httpd      127.0.0.1:8080  =>  127.7.74.1:8080
postgresql 127.0.0.1:5432  =>  127.7.74.2:5432

Press CTRL-C to terminate port forwarding
Run Code Online (Sandbox Code Playgroud)

有关在此处使用PostgreSQL盒式磁带的更多信息,请参阅OpenShift Developer Portal:https://developers.openshift.com/en/databases-postgresql.html

  • 您需要使用 OPENSHIFT_POSTGRESQL_DB_HOST 环境变量以及关联的端口和用户/密码。如果没有端口转发,您将无法从其他云提供商连接到它。如果答案是为您回答的,请记住将答案标记为正确。 (2认同)