关于postgresQL突然退出引发的问题
有时候突然没电导致电脑关机或者别的非正常因素导致postgresQL停止运行,在运行工程时报下面的错误:
“Is the server running on host “localhost” (127.0.0.1) and accepting TCP/IP connections on port 5432?”
然后百度后指引你去 想当然的在终端启动postgresql服务:
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
天啊,怎么办?
别着急 看下log:
cat /usr/local/var/postgresql/server.log
然后反复报下面这些
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 418) running in data directory "/usr/local/var/postgres"?
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 418) running in data directory "/usr/local/var/postgres"?
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 418) running in data directory "/usr/local/var/postgres"?
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 418) running in data directory "/usr/local/var/postgres"?
好吧告诉你们解决方法:
进入postgresql安装目录,删除掉那个pid文件就一切OK了
不知道怎么进入?
终端直接输入 open /usr/local/var/postgres 把里面那个pid文件干掉