1

I have the same issue as: Specifying a username while running initdb causes error in log on start of PostgreSQL process

but I am working on setting up PostgreSQL on Ubuntu 17.04 instead of CentOS. I've read that calling initdb directly in this environment is discouraged because the suite of tools packaged with the software such as pg_createcluster, etc. What differences should I consider if I try initializing with a user other than the default postgres user?

1 Answer 1

1

I've read that calling initdb directly in this environment is discouraged because the suite of tools packaged with the software such as pg_createcluster

Yes, but pg_createcluster can pass through options to initdb, so it makes no difference on the configurability.

From the manpage:

SYNOPSIS
pg_createcluster [options] version name [-- initdb options]

Example:

# pg_createcluster 9.5 test -- --username=daniel
Creating new cluster 9.5/test ...
  config /etc/postgresql/9.5/test
  data   /var/lib/postgresql/9.5/test
  locale en_US.UTF-8
  socket /var/run/postgresql
  port   5433

# pg_ctlcluster 9.5 test start
Redirecting start request to systemctl

# su daniel -c 'psql --cluster 9.5/test -l'
                               List of databases
   Name    | Owner  | Encoding |   Collate   |    Ctype    | Access privileges 
-----------+--------+----------+-------------+-------------+-------------------
 postgres  | daniel | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | daniel | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/daniel        +
           |        |          |             |             | daniel=CTc/daniel
 template1 | daniel | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/daniel        +
           |        |          |             |             | daniel=CTc/daniel
(3 rows)

# pg_dropcluster --stop 9.5 test
Redirecting stop request to systemctl

Your Answer

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

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