1

I would like to have my PostgreSQL database start itself up. But currently need to run the following:

Terminal 1:

sudo su - posgresql
cd /usr/lib/postgresql/9.6/bin/
./postgres -D /usr/local/pgsql/data

Terminal 2:

$ sudo -u postgres psql

I would prefer to only need to run terminal 2 and am unsure why Terminal 1 isn't done automatically.

I was able to confirm that PGDATA is unset by running:

$ pg_ctl start -l logfile
pg_ctl: no database directory specified and environment variable PGDATA unset
Try "pg_ctl --help" for more information.

I found some useful instructions in the postgres manual that say I should be adding /usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data to a /etc/rc.d/rc.local or /etc/rc.local but neither of these dirs exist in on Ubuntu 16.04.

I feel I'm missing a simple command to set PGDATA which will start my server automatically. But I don't know what it is or what file I should store this command in.

Max
  • 227
  • 2
  • 4
  • 7
  • All this is done by the scripts coming with the ubuntu packages you already installed. The answer to what needs to be done manually with PGDATA is:nothing. Your actual problem is the same as in your previous question: the instance does not automatically start for some reason that still has to be researched and understood. – Daniel Vérité Sep 27 '17 at 12:58
  • After 3 days of research, I have found many instances similar to my problem from years ago. Most people edit the entire init.d/postgresql file which is something I'd like to avoid – Max Sep 27 '17 at 13:28

0 Answers0