这个报错全部信息如下:
psql: 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"?
- 首先检查 你PG库是否不是启动在 5432端口上的。如果不是,-p xxxx。
- 检查postgres.conf 文件的配置
listen_addresses = '*'
port = 5447
- 有些人会加入一些软链接,比如
ln -s /tmp/.s.PGSQL.5444 /tmp/.s.PGSQL.5432(并不是正确操作)
其实本质还是跟path环境没有设置好有关。
下面贴一个postgres 家目录下的.bash_profile 文件配置:
PGDATA=/data/postgres/db
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/data/postgres/bin:$PATH
MANPATH=/data/postgres/share/man
LD_LIBRARY_PATH=/data/postgres/lib
export PGDATA
export PATH
export MANPATH
export LD_LIBRARY_PATH