我正在尝试使用以下 2 个命令连接到 postgres DB,但它无法连接到数据库:
- psql -h 10.x.x.x -U postgres -W
- psql -h localhost -U postgres -W
输出:
-bash-4.2$ psql -h 10.x.x.x -U postgres -W
Password:
psql: could not connect to server: Connection refused
Is the server running on host "10.54.48.59" and accepting
TCP/IP connections on port 5432?
-bash-4.2$
-bash-4.2$ psql -h localhost -U postgres -W
Password:
psql: FATAL: Ident authentication failed for user "postgres"
-bash-4.2$
但是当我尝试使用没有 IP 的命令连接到数据库时,它可以工作:
-bash-4.2$ psql -U postgres -W
Password:
psql (11.3)
Type "help" for help.
postgres=#
我也尝试在我的 pg_hba.conf 中包含以下列表:
host all all 127.0.0.1/32 ident
host all all 127.0.0.1/32 md5
host all all 127.0.0.1/32 password
你可以试试...
host all all 127.0.0.1/32 trust
然后
psql -h localhost -U postgres DB