When running bin/initdb demo
I encounter the following error:
The files belonging to this database system will be owned by user "USER_1".
This user must also own the server process.
The database cluster will be initialized with locales
COLLATE: en_US.UTF-8
CTYPE: en_US.UTF-8
MESSAGES: en_US.UTF-8
MONETARY: ur_PK
NUMERIC: ur_PK
TIME: ur_PK
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.
creating directory newDB ... initdb: error: could not create directory "newDB": Permission denied
Running it as root gives me this 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.
What could be the problem here, would appreciate any help.
2
Answers
You dont need to run it with
sudo
. But you need to get permissions before you useinitdb
. Use :usually the path is something like
You can find by typing
pg_config
. The correct path is in the variableBINDIR
.You cannot run initdb with sudo.
The steps prior to
initdb
should be like so:then, make sure you create the main cluster first before creating others
then, you can create others with a name assigned
This should solve that.