无法连接到PostgreSQL服务器
我正在尝试使用此处的说明设置PostgreSQL服务器。 我通过apt-get install postgresql
安装了软件包,现在我就开始了:
sudo -u postgres psql postgres
这给出了错误:
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"?
我猜服务器没有运行,但我不知道如何启动它。 任何提示将不胜感激。
更新 :即使在sudo service postgresql start
后,运行service postgresql status
也不会输出任何内容。
更新#2 :运行ps auxw | grep post
ps auxw | grep post
也没有出现任何东西,所以我猜测服务器守护进程没有运行。
检查当前创建的数据库集群:
pg_lsclusters
如果有一个,但它没有运行,那么启动它(替换版本和名称):
sudo pg_ctlcluster xy name start
如果没有,请创建一个并启动它:
sudo pg_createcluster --start xy name
通常,这应该在您安装软件包时自动发生。 因此,无论是在软件包安装过程中发生了什么事情,还是已经安装了软件包,而且有人已经搞砸了我上面展示的内容。