postgresql port confusion 5433 or 5432?

2019-01-30 07:20发布

I have installed postgresql on OSX. When I run psql, I get

$ psql
psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5433"?

However, from /etc/services

postgresql      5432/udp    # PostgreSQL Database
postgresql      5432/tcp    # PostgreSQL Database
#                          Tom Lane <tgl@sss.pgh.pa.us>
pyrrho          5433/tcp    # Pyrrho DBMS
pyrrho          5433/udp    # Pyrrho DBMS

5433 is occupied by pyrrho, 5432 is assigned to pg. I can connect with

psql -p 5432

but why does psql think it is 5433 and how do I make psql look in the right place by default?

7条回答
做个烂人
2楼-- · 2019-01-30 08:04

Quick answer on OSX, set your environment variables.

export PGHOST=localhost

export PGPORT=5432

Or whatever you need.

查看更多
登录 后发表回答