Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2008
    Posts
    3

    Unanswered: Postgresql server is not asking for a password

    I am running a local Postgres Sql Server and I have a database called my_database.
    I have also create a new user called 'tester' on that database with password 'test_password' but when I give the command line..



    psql -U tester -d my_database

    ..Postgresql server is not asking for a password.

    Any ideas?
    Thank you.

  2. #2
    Join Date
    Dec 2012
    Posts
    43
    If connection to postgresql is established without prompting for a password, it will be one of the following reasons:

    1. There is a file ~/.pgpass with a valid line (database,host,username und password)
    In ~/.pgpass you can store connection information so that psql don't ask for a password.

    2. Postgres username is identical to operating system username
    This works only on local machine by default (See file "pg_hba.conf" below)
    In your example postgresql password of "tester" will not be asked for if operating user "tester" starts psql.

    3. You have changed the file "pg_hba.conf" in postgresql's DATADIR

    The default configuration in "pg_hba.conf" on my server is:
    Code:
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    # "local" is for Unix domain socket connections only
    local   all             all                                     peer
    # IPv4 local connections:
    host    all             all             127.0.0.1/32            ident
    # IPv6 local connections:
    host    all             all             ::1/128                 ident
    If "peer" (or other methods) is changed to "trust" no password will be prompted for any user. (WARNING! security risk!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •