postgresqldatabase-administrationsuperuserapache-age

Getting error initdb: error: cannot be run as root when initializing db on postgresSQL


I am trying to install ApacheAGE and for this I am following the instruction in the following article but I have installed postgres 12 instead of 11. The installation was successful but when I tried to initialize DB using the command sudo ./bin/initdb demo I am getting the following error.

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

How do I fix the issue? Do I need to create another Linux user for this? I am using Ubuntu 22.04. Postgresql version is 12 and is installed in the following directory /usr/lib/postgresql/12/bin.

I created another Linux user, added that to sudoers list, logged in using su command but I am still getting the same error.


Solution

  • Do not use sudo while installing and also while installcheck. This solved the problem I was facing.