Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql Postgres服务已启动,但可以';我无法连接。端口5432上未侦听任何内容_Postgresql - Fatal编程技术网

Postgresql Postgres服务已启动,但可以';我无法连接。端口5432上未侦听任何内容

Postgresql Postgres服务已启动,但可以';我无法连接。端口5432上未侦听任何内容,postgresql,Postgresql,我不知道这是怎么发生的,但我的postgres服务器(9.6.2)已经停止在本地工作。我似乎能够启动它,并使用以下命令停止它: brew服务启动postgresql和brew服务启动postgresql但当我尝试使用psql进行连接时,出现以下错误: psql: could not connect to server: No such file or directory Is the server running locally and accepting connections o

我不知道这是怎么发生的,但我的postgres服务器(9.6.2)已经停止在本地工作。我似乎能够启动它,并使用以下命令停止它:
brew服务启动postgresql
brew服务启动postgresql
但当我尝试使用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.5432"?
当我使用
lsof-I:5432
尝试查看端口5432上是否有任何内容正在侦听时,我什么也没有得到


查看了其他帖子,上面说检查
pg_hba.conf
文件,我确实检查了,但似乎没有问题

我最终通过自制软件重新安装了postgres。这本身还不够。我必须杀死我的数据目录才能让它工作(即
rm-rf/path/to/my/data/directory
),然后使用
initdb
重新构建它


显然,这个解决方案只有在您不关心保存数据的情况下才有效(在我的例子中,它只是我的开发环境的数据,所以我没有)。如果确实要保存数据的副本,我想你还得想些别的办法。

试着运行
pg_ctl start
这是我在使用该命令时遇到的错误:pg_ctl:no database directory specified and environment variable PGDATA unset然后
psql-d PGDATA
其中PGDADA是带有数据的目录检查PostgreSQL数据库日志中的错误。