user1184100
user1184100

Reputation: 6894

psql.exe - password authentication failed in windows

I'm a noob in PostgreSQL. I installed ver 9.2 on windows7. During installation it asked for password and i entered it. Now whenever i run d:\tools\PostgreSQL9.2\bin\psql.exe it asks for password. When i enter the password it doesn't accept and it shows "password authentication failed for user "user1". I have re-installed twice already. Also i tried entering my system password.

I'm trying to get the below command to work

psql.exe -f db/codedb.sql development

What should i do to get this working ?

Upvotes: 21

Views: 51823

Answers (3)

KIRAN KOORA
KIRAN KOORA

Reputation: 21

Here is the simple solution for installation Postgresql without getting errors(cluster errors and authentication errors),i have followed below steps and i got installed postgresql sucessfully

  1. create new user in windows from controlpanel-->user accounts

  2. After logged into new user(whic u hve created) copy postrgresql(.exe) application into any directory(other than 'C') and click on the application to install(dont forget to change the installation directory to which u have copied the application file above).

  3. after completion of installaion change below configurations in postgresql.conf and pg_hba.cof

add like below in your postgresql.conf

listen_addresses = '*'  

add like below in your pg_hba.cof

# IPv4 local connections:
host     all     all     127.0.0.1/32    trust
# IPv6 local connections:
host     all     all     ::1/128     trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
# host   sameuser    postgres    127.0.0.1/32    trust
#host    replication     postgres        ::1/128                 md5 

Upvotes: 2

solaimuruganv
solaimuruganv

Reputation: 29677

change "trust" instead of "md5" in the pg_hba.conf to connect to the database and change your password.

    --------------------configuration in pg_hba.conf---------------
    local   all         all                               trust  
    local   all         postgres                          trust          
    host    all         all         ::1/128               trust

Upvotes: 15

Richard Huxton
Richard Huxton

Reputation: 22893

Try setting the user name when connecting.

psql.exe -U username -d dbname -f somefile.sql

You've probably set up the default "postgres" user during installation. Not sure if you've created any others.

To add other users and databases just connect to as postgres to the postgres database and do something like:

CREATE USER myuser WITH ENCRYPTED PASSWORD 'secret';
CREATE DATABASE mydb OWNER myuser;

If your machine is secure you might also like to set up a password file

Upvotes: 32

Related Questions