3
votes

Installed Postgresql via Homebrew. I wanted to create a new database after unzipping a ".tar". But I have this problem.

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser-P--superuser madeleke13'

bash: createuser-P--superuser: command not found

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser-P-superuser madeleke13'

bash: createuser-P-superuser: command not found

Michael-Adelekes-MacBook:wikiful madeleke13$ sudo su postgres -c 'createuser -P --superuser madelek13'

Password: Enter password for new role: Enter it again:

Michael-Adelekes-MacBook:wikiful madeleke13$ createdb -T template0

newdbPassword:
Password:

createdb: could not connect to database template1: FATAL: password authentication failed for user "madeleke13"

Michael-Adelekes-MacBook:wikiful madeleke13$

I am not understanding why I'm unable to authenticate my username when I have had no problems before.

1
"I have had no problems before" - before what?Milen A. Radev
Nothing unusual in this error. Generally the pg_hba.conf rules are such that a random user has to provide a password to connect to a database. Edit it to use trust as the authentication method if you want passwordless connections.Daniel Vérité
My guess is that you're entering postgres' password for your account. Just a guess thoScott Marlowe
A side comment, but I recommend instead of pasting links to screenshots of your terminal, just paste the terminal content. Easier for all of us.harmic
Just updated for a clearer read. I have been using terminal, github, heroku, all else fine so I wonder why it could not authenticate. My password for Postgres and my username password are the same.Mike Adeleke

1 Answers

3
votes

The issue is the username in this command: sudo su postgres -c 'createuser -P --superuser madelek13'

Notice the username not the same as the user's account name: madeleke13. There's an 'e' missing in the username provided to the createuser command, thus the failed authentication.