Unix 套接字错误 postgresql 9.4 [英] Unix socket error postgresql 9.4

查看:47
本文介绍了Unix 套接字错误 postgresql 9.4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在全新的 15.04 ubuntu 安装上安装了 postgresql 9.4,但无法启动 psql 服务器.每次我尝试运行 sudo -u postgres psql 时,都会出现以下错误:

I just installed postgresql 9.4 on a brand new 15.04 ubuntu install and I'm unable to start the psql server. Every time I try to run sudo -u postgres psql, it gives me the following error:

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.5432"?

我已经尝试了这里和其他所有论坛上发布的每一个解决方案,但没有一个有效:

I have tried every single solution posted here and on every other forum, but none have worked except one:

http://ubuntuforums.org/showthread.php?t=869080

sudo mkdir -p /usr/local/pgsql/data
sudo chown -R postgres:postgres /usr/local/pgsql/
sudo sudo su postgres
cd /usr/lib/postgresql/9.4/bin/
./initdb -D /usr/local/pgsql/data
./postgres -D /usr/local/pgsql/data

我尝试按照那里的说明更改 init.d 脚本,但这不起作用,并且上面的解决方案似乎只能工作一次,之后文件锁定并且我无法运行 ./postgres -D/usr/local/pgsql/data

I tried changing the init.d script as stated there but that doesn't work, and the solution above only seems to work once, after that, a file locks up and I'm unable to run ./postgres -D /usr/local/pgsql/data

有人可以帮忙吗?我试过删除、清除、重新安装、多版本等.每次我都遇到同样的错误.汉克斯!

Can someone please help? I've tried removing, purging, reinstalling, multiple-versions, etc. Every single time I get the same error. hanks! T

推荐答案

psql 不是 PostgreSQL 服务器.它是连接到已经运行的服务器的命令行客户端.

psql is not the PostgreSQL server. It is the command-line client that connects to an already-running server.

您似乎没有运行 PostgreSQL 服务器,因此无法连接.请注意,错误消息显示服务器是否正在运行...

It looks like you had no PostgreSQL server running, so there was nothing to connect to. Note that the error message says Is the server running...

正如您已经注意到的,要启动 PostgreSQL 服务器,您需要运行 postgres -D/path/to/datadir(或者最好是类似 pg_ctl -D/path/to/datadir -w start -l pgstartup.log).

As you have already noted, to start a PostgreSQL server you need to run postgres -D /path/to/datadir (or preferably something like pg_ctl -D /path/to/datadir -w start -l pgstartup.log).

您应该让操作系统在启动时自动执行此操作,而不是手动执行此操作.大多数 PostgreSQL 安装程序和软件包都会为您设置.有些需要额外的步骤来启用它,这将在他们的文档中解释.你没有提到你是如何安装 PostgreSQL/从哪里安装的,所以我不能更具体地说明这一点.

Rather than doing so manually, you should have your operating system do this automatically when you start up. Most PostgreSQL installers and packages will set this up for you. Some require additional steps to enable it, which will be explained in their documentation. You haven't mentioned how you installed PostgreSQL / from where, so I can't be more specific about this.

如果您使用 Ubuntu PostgreSQL 软件包或 http://apt.postgresql.org/ 软件包,它们将为您注册一项服务.

If you use the Ubuntu PostgreSQL packages or http://apt.postgresql.org/ packages, they'll register a service for you.

请参阅https://help.ubuntu.com/community/PostgreSQL

这篇关于Unix 套接字错误 postgresql 9.4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆