在mac中运行如下命令启动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

实际postgresql服务并没有运行起来,重试也一样.

先看一下log:

cat /usr/local/var/postgres/server.log

末尾有这么一句:

lock file "postmaster.pid" already exists HINT: Is another postmaster (PID 584) running in data directory "/usr/local/var/postgres"? LOG: database system was shut down at 2017-02-13 06:54:12 CST LOG: MultiXact member wraparound protections are now enabled LOG: autovacuum launcher started LOG: database system is ready to accept connections FATAL: lock file "postmaster.pid" already exists HINT: Is another postmaster (PID 755) running in data directory "/usr/local/var/postgres"?

进入postgresql的安装目录,删除掉那个pid文件,再次运行一切正常.

怀疑是上次强行退出postgresql造成的.