小编Ser*_*lov的帖子

无法连接到 PostgreSQL unix 域套接字

我正在尝试从 PHP Web 应用程序连接到 PostgreSQL Unix 域套接字。相关系统组件:

  • CentOS 7 x64(强制执行 SELinux)
  • postgresql93 9.3.5-2PGDG.rhel7
  • nginx 1.6.2-1.el7.ngx
  • php-common 5.4.16-23.el7_0.3
  • php-fpm 5.4.16-23.el7_0.3
  • php-pdo 5.4.16-23.el7_0.3
  • php-pgsql 5.4.16-23.el7_0.3

PostgreSQL 正在侦听标准端口 5432,我在 127.0.0.1:5432 通过 TCP/IP 使用它没有问题,但是当我尝试连接到它的 Unix 域套接字时,出现以下错误:

Cannot connect to database: SQLSTATE[08006] [7] could not connect to server:
No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

文件/tmp/.s.PGSQL.5432存在,我可以使用psql连接:

$ psql -Uusername db_name
psql (9.3.5)
Type "help" for help.

db_name=>
Run Code Online (Sandbox Code Playgroud)

所以从 PostgreSQL 方面应该没有问题。或者有吗? …

postgresql nginx centos php-fpm

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

centos ×1

nginx ×1

php-fpm ×1

postgresql ×1