这是我尝试从控制台访问 psql 时得到的。我正在使用自制软件来运行帖子。
atul-new-mac:sites user$ 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"?
我通过以下方式检查了版本:
atul-new-mac:sites user$ which psql
/usr/local/bin/psql
以下是日志文件中的详细信息:
atul-new-mac:sites user$ tail -f /usr/local/var/postgres/server.log
ERROR: could not access status of transaction 0
DETAIL: Could not open file "pg_clog/0000": Permission denied.
LOG: received smart shutdown request
LOG: autovacuum launcher shutting down
LOG: shutting down
PANIC: could not open control file "global/pg_control": Permission denied
LOG: checkpointer process (PID 381) was terminated by signal 6: Abort trap
LOG: terminating any other active server processes
LOG: could not open temporary statistics file "pg_stat/global.tmp": Permission denied
LOG: abnormal database system shutdown
这是我尝试手动启动它时得到的:
atul-new-mac:postgres user$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
pg_ctl: another server might be running; trying to start server anyway
server starting
sh: /usr/local/var/postgres/server.log: Permission denied
您的日志告诉您的 postgresql 实例在权限方面遇到问题(行 ERROR 和 PANIC)并读取您提供的其他数据提取,您可能已经有一个 postgresql 实例正在运行。
要检查它,只需执行以下命令:
ps aux | grep -i "*postgres*"
您应该看到所有 postgresql 进程都在运行。
尝试通过使用 pg_ctl stop 来停止所有这些进程,或者如果什么都没有发生并且进程仍然存在,然后尝试杀死它们(我假设您在开发平台上,所以这不会给其他人带来问题)
kill -9 <postgresID>
然后当所有 postgresql 进程都消失时,尝试启动 postgresql。如果您仍然遇到权限问题,请使用 lsof 工具查看哪个进程锁定了您的文件。