gpt4 book ai didi

postgresql - 服务器是否在本地运行 - Postgresql

转载 作者:行者123 更新时间:2023-11-29 11:41:34 27 4
gpt4 key购买 nike

tameen@tameen-HP:~/Downloads/$ sudo -u postgres 
tameen@tameen-HP:~/Downloads/$ sudo -u postgres psql
[sudo] password for tameen:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?

tameen@tameen-HP:~/Downloads/$ netstat -an | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.0.1:5939 0.0.0.0:* LISTEN
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN

如果它监听端口 5432 并且使用 export PGPORT=5432 它不工作。如何解决这个问题呢?


tameen@tameen-HP:~/Downloads$ sudo su postgres 
postgres@tameen-HP:/home/tameen/Downloads$ createdb template_postgis
could not change directory to "/home/tameen/Downloads": Permission denied
createdb: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"?

最佳答案

通过-p/-h选项提供端口和主机:

sudo -u postgres psql -p 5432 -h 127.0.0.1

createdb -p 5432 -h 127.0.0.1 template_postgis

关于postgresql - 服务器是否在本地运行 - Postgresql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28080665/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com