postgresql - 无法连接到 ubuntu 中的 postgres

标签 postgresql ubuntu

我正在尝试在 ubuntu 上安装 postgresql。 我按照 http://hocuspokus.net/2008/05/install-postgresql-on-ubuntu-804/ 中的步骤操作.

然后输入命令:

psql template1

我收到以下错误:

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

最佳答案

我的问题是我之前安装了 9.1 版,而 9.1 仍在占用默认端口 5432。我可以使用以下命令找到它:

root@labs:/home/caleb# /etc/init.d/postgresql status
9.1/main (port 5432): down
9.2/main (port 5433): online

所以我能够看到我的 9.2 数据库正在端口 5433 上运行。所以要连接,我必须明确指定端口 5433:

psql -p 5433

关于postgresql - 无法连接到 ubuntu 中的 postgres,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8293635/

相关文章:

linux - 为什么 TOP 命令的详细列表中列出的 SWAP 大于摘要中的?

java第二个sql语句不工作

postgresql - 如何在psql上检查连接的用户

django - ufw 禁止 docker 容器连接到 postgres

android - 在 Ubuntu 上设置 Android 主目录。这是多余的吗?

magento - 用于图像的第二个 Linux 服务器(与 Magento 组合)

postgresql - PostgreSQL 中从字符串到 uuid 的迁移

sql - 找到两列之间的最大值并在 postgres 中相应地更新

mysql - SQL 中的引用完整性完整性检查

c++ - 如何在 Ubuntu 14.04.3 LTS 上构建 dolphin (Trusty Tahr)