I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user “postgres” for both console client and Pgadmin. I have typed user as “postgres” and password “postgres”, because it worked before. But now authentication is failed. I did it before a couple of times without this problem. What should I do? And what happens?
psql -U postgres -h localhost -W
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
If I remember correctly the user
postgreshas no DB password set on Ubuntu by default. That means, that you can login to that account only by using thepostgresOS user account.Assuming, that you have
rootaccess on the box you can do:If that fails with a
database "postgres" does not existserror, then you are most likely not on a Ubuntu or Debian server 🙂 In this case simply addtemplate1to the command:If any of those commands fail with an error
psql: FATAL: password authentication failed for user "postgres"then check the file/etc/postgresql/8.4/main/pg_hba.conf: There must be a line like this as the first non-comment line:For newer versions of PostgreSQL
identactually might bepeer. That’s OK also.Inside the
psqlshell you can give the DB userpostgresa password:You can leave the
psqlshell by typing CtrlD or with the command\q.Now you should be able to give pgAdmin a valid password for the DB superuser and it will be happy too. 🙂