Postgresql connection problem on SUSE-9.1

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Derek Fountain

    Postgresql connection problem on SUSE-9.1

    I'm running PHP-4.3.4 and Postgresql 7.4.2 on SUSE-9.1. I have this piece of
    PHP:

    <?php
    $c = pg_connect("use r=derek dbname=webcalen dar");
    ?>

    which produces this error in the browser:

    Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT
    authentication failed for user "derek" .
    in /home/derek/public_html/misc/testpg.php4 on line 3

    And yet, from the command line, it works OK:
    [color=blue]
    >psql -U derek -d webcalendar[/color]
    Welcome to psql 7.4.2, the PostgreSQL interactive terminal.

    Type: \copyright for distribution terms
    \h for help with SQL commands
    \? for help on internal slash commands
    \g or terminate with semicolon to execute query
    \q to quit

    webcalendar=# \dt
    List of relations
    Schema | Name | Type | Owner
    --------+--------------------------+-------+-------
    public | webcal_asst | table | derek
    public | webcal_categori es | table | derek
    public | webcal_config | table | derek
    ....

    There is no password to access this DB, but adding password='' to the
    connection string didn't help. The postgresql error log contains the
    message: '2004-10-18 13:47:26 FATAL: IDENT authentication failed for user
    "derek"'.

    Can anyone tell me what I'm doing wrong?
  • Steve

    #2
    Re: Postgresql connection problem on SUSE-9.1

    Derek Fountain wrote:[color=blue]
    > I'm running PHP-4.3.4 and Postgresql 7.4.2 on SUSE-9.1. I have this piece of
    > PHP:
    >
    > <?php
    > $c = pg_connect("use r=derek dbname=webcalen dar");
    > ?>
    >
    > which produces this error in the browser:
    >
    > Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT
    > authentication failed for user "derek" .
    > in /home/derek/public_html/misc/testpg.php4 on line 3
    >
    > And yet, from the command line, it works OK:
    >
    >[color=green]
    >>psql -U derek -d webcalendar[/color]
    >
    > Welcome to psql 7.4.2, the PostgreSQL interactive terminal.
    >
    > Type: \copyright for distribution terms
    > \h for help with SQL commands
    > \? for help on internal slash commands
    > \g or terminate with semicolon to execute query
    > \q to quit
    >
    > webcalendar=# \dt
    > List of relations
    > Schema | Name | Type | Owner
    > --------+--------------------------+-------+-------
    > public | webcal_asst | table | derek
    > public | webcal_categori es | table | derek
    > public | webcal_config | table | derek
    > ...
    >
    > There is no password to access this DB, but adding password='' to the
    > connection string didn't help. The postgresql error log contains the
    > message: '2004-10-18 13:47:26 FATAL: IDENT authentication failed for user
    > "derek"'.
    >
    > Can anyone tell me what I'm doing wrong?[/color]
    try adding host=localhost to the connect string. This forces the use of
    tcp/ip connections. It *might* work (:

    Steve

    Comment

    • ljb

      #3
      Re: Postgresql connection problem on SUSE-9.1

      nospam@example. com wrote:[color=blue]
      > I'm running PHP-4.3.4 and Postgresql 7.4.2 on SUSE-9.1. I have this piece of
      > PHP:
      >
      ><?php
      > $c = pg_connect("use r=derek dbname=webcalen dar");
      > ?>
      >
      > which produces this error in the browser:
      >
      > Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT
      > authentication failed for user "derek" .
      > in /home/derek/public_html/misc/testpg.php4 on line 3
      >
      > And yet, from the command line, it works OK:
      >[color=green]
      >>psql -U derek -d webcalendar[/color][/color]

      I think: your PostgreSQL pg_hba.conf is set to use "ident" authentication,
      where the ident protocol is used to verify the identity of the connection.
      When running through the web server, the web server's user ID (something
      like "nobody", usually) is returned, which does not match your claimed
      username (user=derek). From command line, you are probably logged in as
      yourself so ident verifies it is you.

      Consider switching from ident to password-based (md5) authentication and
      supplying passwords when connecting. If you stick with ident, you probably
      need a database account for the web server's username.

      Comment

      Working...