How to fix postgresql initdb cannot be run as root error ?

Veröffentlicht am: 31 Mai 2023
auf dem Kanal: Outsource Path
407
1

https://ibmimedia.com/blog/3299/postg...

The PostgreSQL initdb command is used to initialize a new PostgreSQL database cluster.

However, if you try to run initdb as the root user, you will receive the following error message: initdb: error: cannot be run as root

This error message occurs because PostgreSQL does not allow the root user to create or modify database clusters. This is for security reasons, as the root user has full access to the system.

To resolve this error, you need to run initdb as a non-root user. You can do this by logging in as a non-root user and then running the initdb command.

1. Create a non-root user: To begin, We must create a non-root user to run the PostgreSQL server, for which we can run the command: $ sudo adduser postgres

2. Run initdb as a non-root user: We can use the sudo command if we have administrative privileges which will allow us to run the initdb command as a different user. For example, if we have a user named "postgres", we can execute the following command: $ sudo -u postgres initdb

Read the the full details via the website above.


Auf dieser Seite können Sie das Online-Video How to fix postgresql initdb cannot be run as root error ? mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Outsource Path 31 Mai 2023 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 407 Mal angesehen und es wurde von 1 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!