Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.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
在linux中安装postgresql时出错_Linux_Postgresql_Ubuntu_Installation - Fatal编程技术网

在linux中安装postgresql时出错

在linux中安装postgresql时出错,linux,postgresql,ubuntu,installation,Linux,Postgresql,Ubuntu,Installation,我想在我的计算机Linux中安装postgresql,我完成了过程安装,但当我在cmd postgres error中键入psql时,如下所示: 安装PostgreSQL时出错 psql:无法连接到服务器:没有这样的文件或目录 服务器是否在本地运行并接受 Unix域套接字上的连接“/var/run/postgresql/.s.PGSQL.5432” 我是怎么解决的?? 谢谢错误表明psql实用程序找不到连接到数据库服务器的套接字 要么您没有在后台运行数据库服务,要么套接字位于其他位置,或者可能需

我想在我的计算机Linux中安装postgresql,我完成了过程安装,但当我在cmd postgres error中键入psql时,如下所示:

安装PostgreSQL时出错

psql:无法连接到服务器:没有这样的文件或目录 服务器是否在本地运行并接受 Unix域套接字上的连接“/var/run/postgresql/.s.PGSQL.5432”

我是怎么解决的??
谢谢

错误表明psql实用程序找不到连接到数据库服务器的套接字

要么您没有在后台运行数据库服务,要么套接字位于其他位置,或者可能需要修复pg_hba.conf

步骤1:验证数据库是否正在运行

该命令可能因您的操作系统而异。但在大多数*ix系统上,以下功能可以工作,它将在所有正在运行的进程中搜索Postgre

ps -ef | grep postgres
在我的mac osx系统上,这个

501   408     1   0  2Jul15 ??         0:21.63 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
最后一列显示用于启动服务器的命令和选项

您可以使用以下命令查看启动postgres服务器的所有可用选项

man postgres
从这里可以看到选项-d和-r分别是datadir和logfilename。 步骤2:如果postgres服务正在运行

使用find搜索套接字的位置,它应该位于/tmp中的某个位置

sudo find /tmp/ -name .s.PGSQL.5432
如果postgres正在运行并接受套接字连接,上面的内容应该会告诉您套接字的位置。在我的机器上,结果是:

/tmp/.s.PGSQL.5432
然后,尝试显式使用该文件的位置通过psql连接,例如

psql -h /tmp/ dbname
步骤3:如果服务正在运行,但您没有看到套接字

如果找不到套接字,但看到服务正在运行,请验证
pg_hba.conf
文件是否允许本地套接字

浏览到datadir,您应该可以找到pg_hba.conf文件

默认情况下,在文件底部附近,您应该看到以下几行:

# "local" is for Unix domain socket connections only
local       all       all       trust
如果看不到,可以修改该文件,然后重新启动postgres服务