A
A
Artyom Innokentiev2015-11-10 10:55:51
PostgreSQL
Artyom Innokentiev, 2015-11-10 10:55:51

Why is it asking for a password and not letting me into postgres?

PostgeSQL 9.4, Ubuntu 15.10.
Edited pg_hba.conf file :

local   all             postgres                                trust

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

Rebooted:
sudo service postgresql restart
I am writing:
sudo su - postgres
It asks for a password, but the password from root and from my user does not fit.
su - postgres- similarly does not work.
Asks for a password. Why? How to make it so that it immediately goes to posgres and without asking for a password?
PS I remember installing and configuring on digitalocean.com according to this manual - everything was as it should be.
PPS When switching from my user to root and then to postgres - everything works, it starts without a password. But I want my user to switch to posgres without a password.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir, 2015-11-10
@rostel

sudo su - postgres
asks for password for sudo, not for postge

A
Azazel PW, 2015-11-10
@azazelpw

Because you didn't even read what it says.

# "local" is for Unix domain socket connections only
local   all             all                                     trust

Here you allowed everyone from the external network access
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5

Here you set md5 from localhosta IPv4
# IPv6 local connections:
host    all             all             ::1/128                 md5
Тут вы поставили md5 от localhosta IPv6

And it looks like this
# "local" is for Unix domain socket connections only
local   all             all                                     password
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

psql -U postgres -c "ALTER USER postgres PASSWORD 'PASSWORD"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question