V
V
Vladimir Merk2017-05-12 12:43:50
PostgreSQL
Vladimir Merk, 2017-05-12 12:43:50

Postgresql won't start on debian. How to start?

Hello.
I'm trying to install and run postgresql on debian wheezy but nothing comes up.
I am installing from the official wheezy repository.
sudo apt-get install postgresql postgresql-contrib
Ideally, postgres should start immediately after installation, but this does not happen:

[warn] No PostgreSQL clusters exist; see "man pg_createcluster" ... (warning).
Setting up postgresql-9.6 (9.6.2-1.pgdg70+1) ...
Creating new cluster 9.6/main ...
  config /etc/postgresql/9.6/main
  data   /var/lib/postgresql/9.6/main
  locale en_US.UTF-8
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.
child process exited with exit code 1
initdb: removing contents of data directory "/var/lib/postgresql/9.6/main"
Error: initdb failed
Error: could not create default cluster. Please create it manually with

  pg_createcluster 9.6 main --start

or a similar command (see 'man pg_createcluster').
update-alternatives: using /usr/share/postgresql/9.6/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
[warn] No PostgreSQL clusters exist; see "man pg_createcluster" ... (warning).

I tried a dozen ways to start, but the whole point of the errors boils down to the fact that postgresql cannot work as root. However, the same thing happens if you run it as the postgres user, or as the left non-root user.
It does not leave any errors in the directory with logs, only what is in the output.
Why is this happening? How to solve the problem? What else to try?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2017-05-12
@mblp

try:

root#rm -rf /var/lib/postgresql/9.6/main/*
root#chown postgres.postgres /var/lib/postgresql/9.6/main
root#chmod 700 /var/lib/postgresql/9.6/main
root#su postgres
postgres$initdb -D /var/lib/postgresql/9.6/main

C
CompiBox, 2017-05-12
@compibox

Delete and add rap to source.

sudo apt-get update
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo apt-get install postgresql postgresql-contrib
sudo su - postgres

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question