PostgreSQL数据库psql连接报错connections on Unix domain socket “/opt/postgresgl/pgdata/.s.PGSQL.5432“? [postgres@localhost ~]$ psql psql: error: connection to server on socket "/opt/postgresql/pgdata/.s.PGSQL.5432" failed: 没有那个文件或目录 Is the server running locally and accepting connections on that socket?
今天安装了PostgreSQL数据库,在执行psql的时候 报错,报错内容如下:
[postgres@localhost ~]$ psql
psql: error: connection to server on socket "/opt/postgresql/pgdata/.s.PGSQL.5432" failed: 没有那个文件或目录
Is the server running locally and accepting connections on that socket?
问题分析:
1.查看查看参数unix_socket_directories
[postgres@localhost ~]$ cat /opt/postgresql/pgdata/postgresql.conf | grep unix_socket_directories
#unix_socket_directories = '/tmp' # comma-separated list of directories
解决办法:
修改/opt/postgresql/pgdata/postgresql.conf文件中的unix_socket_directories参数,修改如下:
unix_socket_directories='/opt/postgresql/pgdata'
或者在psql中修改也可以
psql -h 127.0.0.1
alter system set unix_socket_directories to '/opt/postgresql/pgdata';
重新postgreSQL服务,问题解决。
推荐阅读
发表评论