Re: psql on Mac

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ozan Kahramanogullari <ozan(dot)kah(at)gmail(dot)com>
Cc: andrej(dot)groups(at)gmail(dot)com, "Cc: Jeff Frost" <jeff(dot)frost(at)gmail(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: psql on Mac
Date: 2018-10-24 09:08:52
Message-ID: 19047.1540372132@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-novice

Ozan Kahramanogullari <ozan(dot)kah(at)gmail(dot)com> writes:
> Thank you, Andrej. I tried the instructions in this website. However, this
> did not provide the desired outcome. I am pasting the command line
> below.Also, the command "psql -h localhost" did not work.

> XXX:src3 ozan$ psql -h localhost
> Password:
> psql: FATAL: password authentication failed for user "ozan"

This definitely indicates that the server thinks you specified password
auth (of one flavor or another). Now this:

> local all all trust

looks like it ought to let everything in without a password, but the
problem is that "local" only means Unix-socket connections. So it
should apply when you say "psql" or "psql -U somebody", but it does
*not* apply to TCP connections which is what you get with "-h localhost".
What you really want, if you just want to let in all same-machine
connections indiscriminately, is this:

# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all trust
host replication all 127.0.0.1/32 trust
host replication all ::1/128 trust

(copied from what I've got on my Mac).

> local postgres postgres trust
> local all postgres trust

These lines are pretty pointless given the previous "local all all"
line; that one will capture any connections that these could match.

> XXX:src3 ozan$ psql -U ozan
> Password for user ozan:
> psql: FATAL: password authentication failed for user "ozan"

This, on the other hand, suggests that you've got still more problems;
this should have matched the "local all all" line, but obviously it
did not. Somewhere the server is finding a pg_hba.conf line that is
telling it to use password authentication. Some possibilities:

1. You aren't editing the right pg_hba.conf file. ("show hba_file"
should confirm where the server thinks that file is. In PG v10 or
newer, the pg_hba_file_rules view is also helpful.)

2. You stuck the lines you're showing us at the bottom of an existing
pg_hba.conf file, not paying attention to earlier lines that would
control what the server does. The rule is that the first entry in
pg_hba.conf that matches the connection request is what's used. So
be sure to delete or comment out rules you don't want.

3. You edited the right file, but didn't restart or reload the server
afterwards, so it's still using old data.

regards, tom lane

In response to

  • psql on Mac at 2018-10-23 22:26:37 from Ozan Kahramanogullari

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Ozan Kahramanogullari 2018-10-24 09:30:36 Re: psql on Mac
Previous Message Tu Trinh Nguyenha 2018-10-24 08:57:42 Can't start postgresql 11

Browse pgsql-novice by date

  From Date Subject
Next Message Ozan Kahramanogullari 2018-10-24 09:30:36 Re: psql on Mac
Previous Message Ozan Kahramanogullari 2018-10-24 06:50:40 Re: psql on Mac