Re: .pgpass being ignored

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Stephen Rasku <srasku(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: .pgpass being ignored
Date: 2013-06-25 14:13:56
Message-ID: CABUevEzeZn-Sjmpj9dFXR2HscfvNO0z-wnhs=c7nfpJ__RN0Ew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, Jun 22, 2013 at 12:19 AM, Stephen Rasku <srasku(at)gmail(dot)com> wrote:
> I am trying to write a script that will create and populate a
> database. I don't want to enter a password every time so I want to
> use a .pgpass file. It has the correct permissions:
>
> $ ls -l $PGPASSFILE
> -rw------- 1 Stephen staff 43 21 Jun 14:48 /Users/Stephen/.pgpass
>
> However, when I call createdb, it fails:
>
> $ createdb -h 192.168.1.4 -U postgres --no-password JobSearch
> createdb: could not connect to database postgres: fe_sendauth: no
> password supplied
>
> This is the contents of my .pgpass file:
>
> 192.168.1.4:5432:DatabaseName:postgres:thisIsTheCorrectPassword
>
> If I omit the --no-password option it will prompt me for a password
> and the command will succeed. I am using 9.0.10 from MacPorts.
>
> What am I doing wrong?

From the error message, the failure is to connect to the database
"postgres". Your .pgpass only has an entry for database
"DatabaseName".

createdb will connect to "postgres" and issue the CREATE DATABASE
command there. You can change tihs with the parameter
--maintenance-db, but tat was added in 9.2 only. But even so, createdb
must connect to an *existing* database in order to issue the CREATE
DATABASE command, so you need a line in .pgpass for whichever
maintenance db you're using.

(also, you should really upgrade to 9.0.13, though that won't change
this specific case)

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sameer Thakur 2013-06-25 14:32:38 Re: Archiving and recovering pg_stat_tmp
Previous Message Pavel Stehule 2013-06-25 13:45:02 Re: greatest cannot be used as sfunc for CREATE AGGREGATE