我在ubuntu Ubuntu 12.04.2 LTS(Precise Pangolin)上安装了三个版本的postgres 8.4,9.1和9.2。版本8.4在端口5433上运行,在端口5432上运行9.1,在端口5434上运行9.2
当我运行postgres status
时,我得到了这个
8.4/main (port 5433): down
9.1/main (port 5432): down
9.2/main (port 5434): online
当我尝试使用psql -U postgres template1
连接到9.2版时,我收到以下错误
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"?
我能做些什么才能让这个工作?希望收到你们的回复。
答案 0 :(得分:1)
@Old Pro。谢谢你的线索。解决方案实际上非常简单。
在我四处寻找之后我终于开始工作了。由于我有三个数据库版本坐在同一个盒子上,但从三个不同的端口运行,我尝试连接到每个数据库时所需要做的是明确指定我想连接到的数据库的端口。 PostgreSQL默认端口是5432所以当连接到我的版本9.1时,我不必指定端口,但我必须在连接到版本8.1和9.2时指定端口号。
我这样做是为了让它发挥作用。
版本8.1在港口5433上运行
psql -p 5433 -U postgres template1
VERSION 9.1在港口5432上运行
psql -p 5432 -U postgres template1
或
psql -U postgres template1
版本9.2在港口5434上运行
psql -p 5434 -U postgres template1