1

I am trying to install postgresql on my MacBook using brew. I ran the command

brew install postgres

and when the download is finished I start the service using

brew services restart postgresql

This works fine, the problem arrises when I either want to log in to psql by running psql in the command line or when I want to create a database using createdb

My problem is that psql asks me for a password to my user which I haven't created. The username is the same as the one for my computer so my first thought was that the password would be the same but alas it was not.

Here is the error I get after answering the password incorrectly a couple of times

psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: FATAL:  password authentication failed for user "<MyUsername>"

I have switched out my actual username for <MyUsername> but you get the point

I have scoured the web for answers to this. Here are the things that I have tried:

  • The password to my computer (several hundreds of times, just to be sure)
  • The default password postgres (supposedly just postgres)
  • The empty password
  • Logging into the postgres (psql -U postgres) user and trying the same passwords.
  • Going into the pg_hba.conf file to change the database administrative login
  • Uninstalling and Reinstalling a couple of times
  • Bashing my head against the wall (really mad this one didn't work)

Hopefully I'm being completely blind and the default password is something obvious

Valdimar
  • 11
  • 3
  • "Logging into the postgres (psql -U postgres) user and trying the same passwords." What errors did this give you? – jjanes Mar 04 '22 at 16:39
  • "Going into the pg_hba.conf file to change the database administrative login" What specifically did you do, and what was the result? For that matter, what did you find in pg_hba.conf to start with? – jjanes Mar 04 '22 at 16:39
  • Did brew ask for a password upon installation? – jjanes Mar 04 '22 at 16:40
  • What was the initial `psql` command you used to connect? Have you read [Brew install](https://wiki.postgresql.org/wiki/Homebrew)? Add answers as update to question. – Adrian Klaver Mar 04 '22 at 16:46

1 Answers1

0

Apparently the bane of my postgres cli was the pgAdmin tool which had accompanied the installation of postgres from postgresql.org. Deleting pgAdmin and following this article to completely uninstall postgres and then reinstalling psql via brew install postgres solved my issue

Valdimar
  • 11
  • 3