我正在尝试从 PHP Web 应用程序连接到 PostgreSQL Unix 域套接字。相关系统组件:
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 方面应该没有问题。或者有吗? …