psql: could not connect to server: No such file or directory
SOLUTION 已验证 - 已更新 2015年三月27日19:52 -
环境
- Red Hat Enterprise Linux 6 (RHEL)
- PostgreSQL database
问题
- We are unable to login the PostgreSQL database of Jon server application using the command psql. Tried to login as postgres and root user, but getting the same error. Please see the error details below and guide us fix this error ASAP.
bash-4.3$ psql
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"?
决议
- The error message indicates that
postgresqlservice is not running and listening to default tcp port 5432. Use the below command and confirm tcp port used bypostgresqlservice. Then use correct command to connect it. For example :
# ps -ef | grep postgres
postgres 6043 1 0 16:20 ? 00:00:00 /usr/bin/postgres -D /var/lib/pgsql/data -p 5454
postgres 6044 6043 0 16:20 ? 00:00:00 postgres: logger process
postgres 6046 6043 0 16:20 ? 00:00:00 postgres: checkpointer process
postgres 6047 6043 0 16:20 ? 00:00:00 postgres: writer process
postgres 6048 6043 0 16:20 ? 00:00:00 postgres: wal writer process
postgres 6049 6043 0 16:20 ? 00:00:00 postgres: autovacuum launcher process
# bash-4.3$ psql rhq --host=localhost --port=5454 --username=rhqadmin --password
Password for user rhqadmin:
psql (9.2.0)
Type "help" for help.
rhq=>
根源
- The
postgresqlservice was running on port 5454 instead of default port 5432.
诊断步骤
- Collect the following commands output and check tcp port used by
postgresqlservice
# ps -ef | grep postgres
# netstat -tulnp | grep postgres

本文档详细解释了在Red Hat Enterprise Linux 6环境下,使用psql命令连接PostgreSQL数据库遇到“No such file or directory”错误的原因及解决方案。通过确认postgresql服务是否运行在默认TCP端口5432上,并提供了检查服务运行状态和更改连接参数的方法。
2134

被折叠的 条评论
为什么被折叠?



