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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20960407/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:15:24  来源:igfitidea点击:

OpenShift: How to connect to postgresql from my PC

postgresqlopenshift

提问by user2705169

I have an openshift app, and I just installed a postgresql DB on the same cartridge.

我有一个 openshift 应用程序,我刚刚在同一个墨盒上安装了一个 postgresql 数据库。

I have the postgresql DB installed but now I want to connect to the DB from my PC so I can start creating new tables.

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

Using port forwarding I found my IP for the postgresql db to be

使用端口转发,我发现 postgresql db 的 IP 是

127.3.146.2:5432

127.3.146.2:5432

under my webaccount I see my Database: txxx User: admixxx Password: xxxx

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

Then Using RazorSQl I try to setup a new connection

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

keeps coming as user password incorrect.

不断出现,因为用户密码不正确。

If I try and use the local IP to connect such as the 127.0.0.1 then I can connect fine.

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

How can I resolve this issue, all I am trying to do is connect to this DB so that I can create new tables.

我该如何解决这个问题,我所要做的就是连接到这个数据库,以便我可以创建新表。

回答by

As shown below, after running the "rhc port-forward $appname" command, you would need to connect to the ip address of 127.0.0.1 and port that shows up next to it to connect to the service you want to reach, such as postgresql. In the below example, i would connect to 127.0.0.1, port 5432. If you already have something running locally on the postgresql port, it will select another port and display it in the table. But the connection will be forwarded to your openshift gear and postgresql on your gear.

如下图,运行“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

You can refer to the OpenShift Developer Portal for more information about using the PostgreSQL cartridge here: https://developers.openshift.com/en/databases-postgresql.html

您可以在此处参考 OpenShift 开发人员门户,了解有关使用 PostgreSQL 盒式磁带的更多信息:https: //developers.openshift.com/en/databases-postgresql.html