Попробуйте удалить постгрес полностью, те с pure
apt-get --purge remove postgresql\*
userdel -r postgres
groupdel postgres
rm -r /var/lib/postgresql/
rm -r /etc/postgresql-common/
rm -r /etc/postgresql/
sudo apt-get install postgresql postgresql-contrib
"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
su -l postgres -c 'pg_createcluster 9.6 main --start'
install: cannot change owner and permissions of `/etc/postgresql/9.6': No such file or directory
install: cannot create directory `/etc/postgresql/9.6': Permission denied
Error: could not create configuration directory; you might need to run this program with root privileges
su -l postgres -c 'pg_createcluster 9.6 main --logfile=/var/log/psql.log --user=postgres --group=postgres --start'
Running in debug mode.
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
VERSION=9.6.2
PGDATA=/var/lib/postgresql/9.6/main
share_path=/usr/share/postgresql/9.6
PGPATH=/usr/lib/postgresql/9.6/bin
POSTGRES_SUPERUSERNAME=postgres
POSTGRES_BKI=/usr/share/postgresql/9.6/postgres.bki
POSTGRES_DESCR=/usr/share/postgresql/9.6/postgres.description
POSTGRES_SHDESCR=/usr/share/postgresql/9.6/postgres.shdescription
POSTGRESQL_CONF_SAMPLE=/usr/share/postgresql/9.6/postgresql.conf.sample
PG_HBA_SAMPLE=/usr/share/postgresql/9.6/pg_hba.conf.sample
PG_IDENT_SAMPLE=/usr/share/postgresql/9.6/pg_ident.conf.sample
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
postgres:/$ initdb -D /var/lib/postgresql/9.6/main
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/9.6/main ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... "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"
Какая ос и версия ос?
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
/var/log/syslog начало сбоя, там ещё 200 таких строк
/var/log/syslog начало сбоя, и ещё 150 строк после