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

Pubblicato il: 31 maggio 2023
sul canale di: 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.


In questa pagina del sito puoi guardare il video online How to fix postgresql initdb cannot be run as root error ? della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Outsource Path 31 maggio 2023, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 407 volte e gli è piaciuto 1 spettatori. Buona visione!