psql: error: connection to server on socket “/opt/postgresgl/pgdata/.s.PGSQL.5432“ failed

发布于:2023-09-14 ⋅ 阅读:(102) ⋅ 点赞:(0)

PostgreSQL数据库psql连接报错connections on Unix domain socket “/opt/postgresgl/pgdata/.s.PGSQL.5432“?
[postgres@localhost ~]$ psgl
psql: error: connection to server on socket "/opt/postgresgl/pgdata/.s.PGSQL.5432" failed: 没有那个文件或目录
Is the server running locally and accepting connections on that socket?

今天安装了PostgreSQL数据库,在执行psql的时候 报错,报错内容如下:

[postgres@localhost ~]$ psgl
psql: error: connection to server on socket "/opt/postgresgl/pgdata/.s.PGSQL.5432" failed: 没有那个文件或目录
Is the server running locally and accepting connections on that socket?

问题分析:

1.查看查看参数unix_socket_directories

[postgres@localhost ~]$ cat /opt/postgresgl/pgdata/postgresql.conf | grep unix_socket_directories
#unix_socket_directories = '/tmp'       # comma-separated list of directories

解决办法:

修改/opt/postgresgl/pgdata/postgresql.conf文件中的unix_socket_directories参数,修改如下:

unix_socket_directories='/opt/postgresgl/pgdata'

重新postgreSQL服务,问题解决。