FATAL ERROR lock file “postmaster.pid” already exists

后端 未结 7 1725
故里飘歌
故里飘歌 2021-02-03 20:26

I have recently installed PostGIS on my Mac (El Capitan 10.11.4, Postgres is version 9.5.1) using Homebrew, and I am following these instructions - http://morphocode.com/how-to-

相关标签:
7条回答
  • 2021-02-03 20:52

    Posting this in case it helps someone else:

    I was having this same problem as the OP after a hard reboot when my laptop crashed. What helped me was running the following command to see what PID was associated with postmaster.pid:

    cat /usr/local/var/postgres/postmaster.pid
    

    The first number that appears will be the PID. Looking in Activity Monitor, I was able to see that Postgres was running, but without a PID number that matched the one shown.

    Instead of the steps outlined in the answer referenced on Superuser, I restarted my laptop properly and then opened up Terminal and ran

    brew services restart postgresql
    

    This worked without having to remove postmaster.pid, which I saw a few other posts recommend. Sometimes it's the simple solutions that work.

    0 讨论(0)
  • 2021-02-03 20:53

    It often happens to me in OSx, when my system shutdown unexpectedly.

    You can just remove the file postmaster.pid.

    cd Library/Application Support/Postgres/var-{postgres-version}
    

    and remove the postmaster.pid file

    restart the Postgres by using this command

    pg_ctl -D /usr/local/var/postgres restart
    
    0 讨论(0)
  • 2021-02-03 20:57

    If you have installed postgres with brew then simply run the following command and it will manage everything

     brew services restart postgresql
    
    0 讨论(0)
  • 2021-02-03 21:06

    If you got no important data to lose :

    sudo killAll postgres
    brew services restart postgresql
    

    AGAIN : You could get data corrupted by doing this !

    do it at your own risk !

    0 讨论(0)
  • 2021-02-03 21:07

    Postmaster is the main PostgreSQL process. You're trying to start PostgreSQL that's already running (and you're saying yourself you can connect to it). Just skip that step of your process.

    0 讨论(0)
  • 2021-02-03 21:09

    Since you can connect to the database, you don't need to start the server again - it's already running.


    pg_ctl is used to control the PostgreSQL server. Since your server is already started, your command:

    pg_ctl -D /usr/local/var/postgres start
    

    Returns an error, saying that there is a lock on postmaster.pid - which is true since there is already a server running under that PID.


    There are two ways:

    1. The most basic way - skip that step, your server is already running!
    2. Executing a needless operation - stopping the server, and then starting it again.

    You could stop your server doing :

    pg_ctl -D /usr/local/var/postgres stop
    

    So that you won't have the lock on postmaster anymore and you could use your command to start it again.

    0 讨论(0)
提交回复
热议问题