连接到PostgreSQL给出“不能连接到服务器”错误 [英] Connecting to PostgreSQL gives "could not connect to server" error
问题描述
我有三个版本的postgres在ubuntu Ubuntu 12.04.2 LTS(Precise Pangolin)上安装了8.4,9.1和9.2。当我运行 postgres status
时,版本8.4在端口5433上运行,在端口5432上运行9.1,在端口5434上运行9.2.
<我得到这个
8.4 / main(port 5433):down
9.1 / main(port 5432):down
9.2 / main(port 5434):online
当我尝试连接到版本9.2 psql -U postgres template1
我得到以下错误
psql:不连接到服务器:没有这样的文件或目录
服务器是否在本地运行,并在Unix域套接字/var/run/postgresql/.s.PGSQL.5432上接受
连接?
我该怎么做才能使这项工作?希望能听到你的声音。
@Old Pro。感谢您的线索。解决方案如果实际上很简单。
在poking后,我终于得到它的工作。由于我有三个数据库版本坐在同一个盒子上,但运行从三个不同的端口,我需要做的时候尝试连接到每个数据库是明确指定数据库我想连接到的端口。 PostgreSQL默认端口是5432,所以当连接到我的版本9.1我不必指定端口,但我必须指定连接到版本8.1和9.2的端口号。
psql -p 5433 -U postgres template1
strong> VERSION 9.1 RUNNING ON PORT 5432
psql -p 5432 -U postgres template1
或
code> psql -U postgres template1
VERSION 9.2 RUNNING ON PORT 5434
psql -p 5434 -U postgres template1
I have three versions of postgres installed 8.4,9.1 and 9.2 on ubuntu Ubuntu 12.04.2 LTS (Precise Pangolin). Version 8.4 is running on port 5433, 9.1 on port 5432 and 9.2 on port 5434
when i run postgres status
i get this
8.4/main (port 5433): down
9.1/main (port 5432): down
9.2/main (port 5434): online
When i try to connect to version 9.2 using psql -U postgres template1
i get 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"?
What can i do to get this working? Hoping to be hearing from you guys.
@Old Pro. Thanks for your clue. The solution if actually very simple.
After poking around i finally got it working. Since i have three database versions sitting on the same box but running from three different ports all i need do when trying to connect to each database is to explicitly specify the port to which database i want to connect to. PostgreSQL default port is 5432 so when connecting to my version 9.1 i don't have to specify the port but i have to specify the port number when connecting to version 8.1 and 9.2.
I did this to get it working.
VERSION 8.1 RUNNING ON PORT 5433
psql -p 5433 -U postgres template1
VERSION 9.1 RUNNING ON PORT 5432
psql -p 5432 -U postgres template1
OR
psql -U postgres template1
VERSION 9.2 RUNNING ON PORT 5434
psql -p 5434 -U postgres template1
这篇关于连接到PostgreSQL给出“不能连接到服务器”错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!