How to check status of PostgreSQL server Mac OS X

前端 未结 7 1907
南旧
南旧 2020-12-04 06:52

How can I tell if my Postgresql server is running or not?

I\'m getting this message:

[~/dev/working/sw] sudo bundle exec rake db:migrate 
rake aborte         


        
7条回答
  •  孤街浪徒
    2020-12-04 07:36

    You can run the following command to determine if postgress is running:

    $ pg_ctl status
    

    You'll also want to set the PGDATA environment variable.

    Here's what I have in my ~/.bashrc file for postgres:

    export PGDATA='/usr/local/var/postgres'
    export PGHOST=localhost
    alias start-pg='pg_ctl -l $PGDATA/server.log start'
    alias stop-pg='pg_ctl stop -m fast'
    alias show-pg-status='pg_ctl status'
    alias restart-pg='pg_ctl reload'
    

    To get them to take effect, remember to source it like so:

    $ . ~/.bashrc
    

    Now, try it and you should get something like this:

    $ show-pg-status
    pg_ctl: server is running (PID: 11030)
    /usr/local/Cellar/postgresql/9.2.4/bin/postgres
    

提交回复
热议问题