psql.exe - password authentication failed in windows

后端 未结 3 1379
小蘑菇
小蘑菇 2021-02-05 07:57

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.ex

相关标签:
3条回答
  • 2021-02-05 08:38

    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

    0 讨论(0)
  • 2021-02-05 08:52

    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
    
    0 讨论(0)
  • 2021-02-05 09:00

    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 
    
    0 讨论(0)
提交回复
热议问题