3

When I execute heroku db:pull it finds my local dev db at:

postgres://127.0.0.1/myapp_development?encoding=utf8

once I confirm though, it fails with:

Sequel::DatabaseConnectionError -> PGError: fe_sendauth: no password supplied

I tried running the pull with the local db specified, e.g.

heroku db:pull postgres://root:@localhost/db_name

which gives the same no password supplied error.

I thought I may need to change root: to myname: because thats the user I granted superuser rights to when I setup postgres but neither root: or myname: works

My database.yml has username: and password: blank for all databases specified.

From the command line as myname@ubuntu I can type psql myapp_development and connect fine and run selects.

What am I missing here?

Is it related to my pg_hba.conf settings? I had a look inside that and it says:

# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

Should 'trusted' be used there? And if so if I edit that file do I need to restart postgres? And if 'trust' is necessary then how come rails and the psql command line tools work without passwords when logged in as my myname user?

Thank you!

Dave
  • 11,392
  • 5
  • 31
  • 42

1 Answers1

5

Authentication method trust might do the trick, but as you are undoubtedly aware, this is not secure.
After editing pg_hba.conf, you don't have to restart. A reload is enough (quoting the manual):

The pg_hba.conf file is read on start-up and when the main server process receives a SIGHUP signal. If you edit the file on an active system, you will need to signal the postmaster (using pg_ctl reload or kill -HUP) to make it re-read the file.

pg_ctl reload

See the fine manual. You might need the manual for version for 8.3. Shared db on heroku currently runs on PostgreSQL 8.3. (Also, I doubt you have access to pg_ctl on heroku.)

Be aware of this:

If no password has been set up for a user, the stored password is null and password authentication will always fail for that user.

Emphasis mine. You might be able to log in locally, because the auth-methods ident or peer allow for that. But for your purpose you may need a password!

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
  • 4
    Sir, you are a gentleman and a scholar. The key point was your quote about null passwords meaning authentication for the user always failed. One ALTER of my superuser later to give him a password and a few minutes later I am browsing my freshly pulled db from heroku locally. Thank you. – Dave Oct 05 '11 at 20:47
  • 4
    @Dave: I bow to your kind words and share your delight. :) – Erwin Brandstetter Oct 05 '11 at 20:49