How to check status of PostgreSQL server Mac OS X

前端 未结 7 1908
南旧
南旧 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:38

    The pg_ctl status command suggested in other answers checks that the postmaster process exists and if so reports that it's running. That doesn't necessarily mean it is ready to accept connections or execute queries.

    It is better to use another method like using psql to run a simple query and checking the exit code, e.g. psql -c 'SELECT 1', or use pg_isready to check the connection status.

提交回复
热议问题