DISCLAIMER: This is for postgresql 10 and ubuntu 18.04, and may or may not work for other versions.
Follow the answer provided by Mr Robot
except recognize:
- The user and group are
postgres
, so the commands should usechown -R postgres:postgres ...
- I'm not sure what's up with
/lib/systemd/system/postgresql.service
whichalthough somehow/lib/systemd/system/[email protected]
manages a PostgreSQL cluster? Either way I edited to become:guess it was already running by the time I followed the instructions, and after reboot (which should be unnecessary?) it came back online, so I guess it works.
# systemd service for managing all PostgreSQL clusters on the system. This
# service is actually a systemd target, but we are using a service since
# targets cannot be reloaded.
[Unit]
Description=PostgreSQL RDBMS
[Service]
User=postgres
Group=postgres
Type=oneshot
ExecStart=/usr/lib/postgresql/10/bin/pg_ctl start -D /etc/postgresql/10/main -l /etc/postgresql/10/main/postgresql.log
ExecReload=/usr/lib/postgresql/10/bin/pg_ctl reload
RemainAfterExit=on
[Install]
WantedBy=multi-user.target
which can be run by systemctl daemon-reload
and service postgresql start
although somehow it was already running? Again, I'm not so familiar with how a PostgreSQL cluster works so possibly this service change is entirely unnecessary, I don't know.