-1

There are PG 9.5 and 11 installed on one server and I would like psql command line to be connected to 11 db server. How can I do that? I can psql to command line but there is only tables from 9.5 db sever available. I use pgadmin 4.

Here is the list of db servers:

enter image description here

3

You need to specify the correct port for your installed server instance. psql -h <Host> -p <Port> can be used to specify the TCP endpoint for your desired server. If you have 2 servers running then they must differ in the configured port.

If your -h Parameter starts with a slash it will not use TCP but assume you have specified the name of a local unix domain socket (which only works on the DB machine and not under Windows. I think by default the path includes the port number as well)

There are also environment variables which can be used instead or via .pg_service.conf.

See https://www.postgresql.org/docs/current/app-psql.html „Connecting to a Database“.

  • host name is the physical server name. But how to specify the db server name in connection? – user938363 Mar 30 at 23:41
  • You only specify the network address of the server (typically the hostname the server runs on). If you have multiple servers on that machine they are differentiated by the numerical port, only. – eckes Mar 31 at 3:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.