postgresql - psql won't login, while pgAdmin logs me in successfully? Wrong command? -
i have remote machine , trying log-in postgres database following command (run linux root
user via ssh
, i.e. locally on machine):
# psql -d mydatabase -u postgres -w password user postgres: <here goes password> psql: fatal: peer authentication failed user "postgres"
for reason fails (tried ~5 times).
but when login same database using pgadmin (i.e. remotely) same role (postgres) , same password, logs in every time.
what's wrong psql
command use? if correct, can suggest troubleshooting steps?
edit: problem in pg_hba.conf
remote , local connections treated differently. remote ones configured properly. question why locals don't work.
for locals, have in pg_hba.conf
:
# "local" unix domain socket connections local peer # ipv4 local connections: host 127.0.0.1/32 md5
do understand correctly localhost
connections first tries peer authentication, , if fails doesn't attempt md5
, returns error?
psql in default trying login via peer. means, have logged in postgres on local machine. can force psql use tcp/ip, need tpo specify host, can localhost, call like:
psql -u postgres -h 127.0.0.1
another way adjust settings. see 2 ways change current local settings:
# "local" unix domain socket connections local peer # ipv4 local connections: host 127.0.0.1/32 md5
1) allow users login without password localhost setting line
local trust
this dangerous , shouldn't done imho.
2) way create database user same user name system login , grant rights account
and of course, in such cases: run psql in context of postgres user e.g. sudo -u postgres psql or su -u postgres -c "psql ..."
Comments
Post a Comment