Reputation: 547
How do I open a postgres database created using psql (i.e. in the terminal) in PgAdmin4 and vice versa?
I also noticed that the localhost port for psql is 5432
and for PgAdmin4 is 5433
.
Is this correct?
Upvotes: 0
Views: 526
Reputation: 19742
Some background is in order. When you install Postgres you create an instance of a server that comes with three databases already created; template0, template1 and postgres. On a given machine you can create more then one Postgres server/instance and have them run simultaneously. In order for that to happen though each server needs to listen on a different port. The default port is the 5432
you mention above. It would seem you also have another server running on port 5433
. I'm guessing what you want to know is about connecting to a given server rather then a database in that server. In that case it is important to know that Postgres works on the server/client model where it is the server and in your case psql
and pgAdmin
are the clients. What this means is that a Postgres server is not tied to a client, it exists on its own. It also means a client can connect to any Postgres server it can reach, assuming it is using the correct credentials. All of the previous means, yes you can connect psql
and/or pgAdmin
to either server. For psql
specify the correct port
using -p
. For pgAdmin
you will need to set up a server using the server dialog Dialog. Then use the appropriate port
in the connection tab.
Upvotes: 1