Installation Problem when Connecting to PostgreSQL

Events happening in the community are now at Drupal community events on www.drupal.org.
ibtehal2001's picture

I've been trying to install Drupal for a few days now on Fedora 6 with a PostgreSQL server, but when I reach the step where I have to configure the database I always get the same error: Can not connect to your PostgreSQL server. Are you sure you have the correct username and password etc...
Although I can login on to the PostgreSQL server from the PHPPgAdmin successfully.
I've tried so many proposed solutions I've found here and on other sites but without any success. I checked the pgsql settings and they're all fine. I ran a php script using pg_connect to check the connection and it always fails, so it's a problem with PHP and pgSQL I assume.

Does anyone have some kind of solution for this problem? I need to install Drupal ASAP.

Comments

Just a guess, did you

earnie@drupal.org's picture

Just a guess, did you specify the correct port? It's under the advanced tab.

This probably isn't the best support forum; see http://drupal.org/support for better options.

Sound to me like auth problems

fiasco's picture

I'm not familiar with Fedora installations but on ubuntu and debian PostgreSQL is set up so that only unix users can connect to locally with the same db username as the unix username i.e this will work:

fiasco@debian:$ psql -u fiasco drupal

but this won't:
fiasco@debian:$ psql -u drupal drupal

because I'm not the unix user drupal

to fix it, you'll need to edit your pg_hba.conf which requires root privilages

sudo vim /etc/postgresql/8.3/main/pg_hba.conf

in there you'll find something like:

# "local" is for Unix domain socket connections only
local   all         all                               ident sameuser

this means for 'local' connections for 'all' databases and 'all' users, use 'ident sameuser' as the method for authentication
we need to add rule here to allow the drupal user/s to connect
local   all         drupal                            ident drupal

this says: for 'local' connections on 'all' databases using the 'drupal' username use 'ident drupal' as the method of authentication

This will mean when you do something like "fiasco@debian:$ psql -u drupal mydb" PostgreSQL will look up pg_ident.conf to see if fiasco can connect as the user 'drupal'.

So the last step is to edit /etc/postgresql/8.3/main/pg_ident.conf and add in:

# MAPNAME     IDENT-USERNAME    PG-USERNAME
drupal        www-data          drupal
drupal        fiasco                drupal

this will allow the unix users www-data and fiasco to connect as the drupal user locally.

its worth noing that the method 'ident drupal' is actually 'ident MAPNAME' where MAPNAME is the name defined in pg_ident.conf

hope that makes sense

ident

ibtehal2001's picture

I have the permissions set to md5, so I don't think I'll be needing all this. And I'm working from the 'root' account.
I gave it a try anyway but without any luck..

you'll also need to restart

fiasco's picture

you'll also need to restart postgres

sudo /etc/init.d/postgres-8.3 restart

postgres doesn't have a root account

fiasco's picture

MySQL has a root account but PostgreSQL's root user is 'postgres'. As per http://www.postgresql.org/docs/8.2/static/auth-pg-hba-conf.html the md5 method requires you to provide a md5 encrypted has as the password apposed to your normal password.

If you can trust the host the connection is coming from (localhost?) then why not set it to 'trust' and not use a password?

It Worked!

ibtehal2001's picture

It finally worked! I set it to 'trust' and tried configuring the database without a password and it worked fine.

Thank you VERY much! You're a life saver :)

Postgresql

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: