6

Anyone to help me solve this issue that has been on my case for the last couple of hours? I have so far tried all suggested solutions but can't seem to find anything working.

Error:

"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.

I will forever be grateful to anyone who helps me solve this.

Kas Barlow
  • 101
  • 2
  • 7

2 Answers2

2

Steps to properly install Postgres via Homebrew on Mac M1:

  1. brew install postgres [Maybe you need to use the alternative install method, as described here: https://docs.brew.sh/Installation#alternative-installs]

  2. initdb /Users/<username>/db -E utf8 [This initializes postgres to use the given directory as the database directory. Normally it is not adviced to use the user directory for database storage.]

  3. pg_ctl -D /Users/<username>/db -l logfile start [After getting success with step 2 it will prompt to run step 3. This command manually starts the server.]

Jonas Deichelmann
  • 3,513
  • 1
  • 30
  • 45
0

Try, change you user in postgres

Switching Over to the postgres Account Switch over to the postgres account on your server by typing: sudo -i -u postgres You can now access a Postgres prompt immediately by typing: psql This will log you into the PostgreSQL prompt, and from here you are free to interact with the database management system right away. Exit out of the PostgreSQL prompt by typing: \q This will bring you back to the postgres Linux command prompt. Accessing a Postgres Prompt Without Switching Accounts You can also run the command you’d like with the postgres account directly with sudo. For instance, in the last example, you were instructed to get to the Postgres prompt by first switching to the postgres user and then running psql to open the Postgres prompt. You could do this in one step by running the single command psql as the postgres user with sudo, like this: sudo -u postgres psql This will log you directly into Postgres without the intermediary bash shell in between. Again, you can exit the interactive Postgres session by typing: \q Many use cases require more than one Postgres role. Read on to learn how to configure these.

CrltsMrtnz
  • 49
  • 1
  • 5
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 20 '22 at 04:59
  • Hello @CrltsMrtnz, thanks for your answer. It has details that I will definitely try out. That said, I actually gave up on running postgresql server as a service using brew. I decided to use the postgres app together with pgAdmin and dbeaver. This helped me run the server without any issues. Though for some reason, postgres was still running in the background so I killed the process and all things are working fine. I guess I will stick with this from now on. – Kas Barlow Feb 21 '22 at 04:45
  • hi @Kas Barlow This work fine for me 1- install BREW. $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 2- follow this video steps https://www.youtube.com/watch?v=QaZrWIvAFsA Maybe need code:Matar proceso si el puerto 5432 está en uso $ sudo pkill -u db-name – CrltsMrtnz Feb 21 '22 at 12:06