Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

OpenShift: How to connect to postgresql from my PC

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

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.

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

127.3.146.2:5432

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

Then Using RazorSQl I try to setup a new connection

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.

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...