pgadmin3 server connection and authentication error

muradin picture muradin · Nov 4, 2013 · Viewed 30.2k times · Source

I have recently installed postgresql 9.1 and pgadmin3. But I can't connect to server which I created with this config:

name: mydb
host: 127.0.0.1
port: 5432
service: 
Maintenance DB: postgres
username: postgres
password: *

According to similar problems I've set my /etc/postgresql/9.1/main/pg_hba.conf file under ubuntu 12.04 LTS like this:

local   all             postgres                                md5

# TYPE  DATABASE        USER            ADDRESS                 METHOD

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

host    all             all             localhost               trust

But when I want to connect to the server I get this error:

Error connecting to the server: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"

Answer

muradin picture muradin · Dec 5, 2013

That was simple after installation of postgresql i should change the postgres user password and my failure was because of that. The password can simply change through this commands under ubuntu 12.04 LTS:

sudo -u postgres psql

And then in psql:

\password

Now enter the new password and re-enter it. That's OK! then you can simply sign in. This way there is no need to change the configuration of pg_hba.conf file.

In fact i failed to login because of my invalid password!