Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

password authentication failed for user "postgres" [duplicate]

I have installed PostgreSQL server 8.4 on my CentOS server sucessfully. After that, I login to CentOS server by using 'postgres' user, but I can not run any command, the error occur:

password authentication failed for user "postgres"

Here is some configurations in pg_hba.conf and postgresql.conf:

--------------------configuration in postgresql.conf-----------
listen_addresses = '*'

--------------------configuration in pg_hba.conf---------------
local   all         all                               md5  
local   all         postgres                          md5 
host    all         all         127.0.0.1/32          md5  
host    all         all         ::1/128               md5
like image 951
Chan Pye Avatar asked Aug 12 '11 09:08

Chan Pye


2 Answers

I tend to use the following in pg_hba.conf:

# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
local   all         all                               md5
host    all         all         127.0.0.1/32          md5
host    all         all         ::1/128               md5

That means that once you're "postgres", you don't need a password, but you need sudo rights to become postgres, so that's pretty darn secure. Any other user can login using simple md5 authentication, which means you don't have to sudo all over the place. This works well for me.

like image 129
Berry Langerak Avatar answered Oct 04 '22 12:10

Berry Langerak


Ensure you use the password of the postgres PostgreSQL account, not the postgres system account. Try "trust" instead of "md5" in the pg_hba.conf to connect to the db an change your pass.

like image 20
Daniel Avatar answered Oct 04 '22 13:10

Daniel