0

I'm using Postges 9.6 on Ubuntu Linux 16. I'm trying to figure out how the Postgres server was installed so I can figure out a command to start and stop it. It evidently isn't installed as a Linux service

[rails@server ~]$ sudo service postgresql status
Redirecting to /bin/systemctl status postgresql.service
Unit postgresql.service could not be found.

"which psql" reveals

[rails@server ~]$ which psql
/usr/bin/psql

I'm sort of at a loss for the next steps in figure out the command to start and stop it.

8
  • What does dpkg -l | grep postgres say? Nov 8, 2019 at 22:20
  • It returns nothing
    – Dave
    Nov 8, 2019 at 22:27
  • What about locate postgres? It might produce a lot of output. Nov 8, 2019 at 22:28
  • Sure did. I coudl include all of it as an edit to my question but probably the most relevant thing it spat back was "/usr/pgsql-9.6/bin/postgres".
    – Dave
    Nov 8, 2019 at 22:35
  • How about dpkg -S "/usr/pgsql-9.6/bin/postgres"?
    – jjanes
    Nov 9, 2019 at 0:17

1 Answer 1

1

If you are simply looking to start and stop it, and a service or systemctl module doesn't exist on your machine, you can use pg_ctl to start and stop the Postgres server. You will also need to have the path to the data directory handy (typically, the folder that contains postgresql.conf and pg_hba.conf), and pass that in along with the -D flag:

pg_ctl -D /path/to/data_dir start|stop

If no data directory exists, you will either need further assistance to help you get an existing database cluster up and running, or you can use initdb to create a new database cluster

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.