Subject: initdb

From: PG Doc comments form <[email-masked]>
Date: Mon, 15 Jan 2018 21:30:24 +0000

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.6/static/app-initdb.html
Description:

So I was trying to create a new db with initdb.  I tried to run this with
the postgres user after installing the server rpm and it failed with runuser
may not be run as non-root users.   So then for fun I tried to run init db
as the root user which should have failed but instead it just reported
initializing database ... OK

According to the documentation this should have failed.  This is on centos
kernel version 3.10.0-693.11.6 and I was using the 9.6 repo.

---

From: Tom Lane <[email-masked]>
Date: Mon, 15 Jan 2018 16:56:06 -0500

> initializing database ... OK

hmm, worksforme:

$ sudo initdb -D someplace
initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

Were you actually running initdb directly, or some script that perhaps
sudo'd internally?

			regards, tom lane

---

From: Scott Watson <[email-masked]>
Date: Mon, 15 Jan 2018 17:11:37 -0500

Hi Tom,

I was running initdb command when calling the postgresql96-setup command.
  Trying to run this as the user postgres failed.

/usr/pgsql-9.6/bin/postgresql96-setup initdb

The database was created under /var/lib/pgsql/9.6/data

thanks
Scott.