For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > June 2007 > DBIx::Simple, authentication fails









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author DBIx::Simple, authentication fails
Justin Catterall

2007-06-27, 7:05 pm


I have the following code to connect to a database:

#!/usr/bin/perl

use warnings ;
use strict ;
use DBIx::Simple ;
use SQL::Abstract ;
use CGI qw/:standard/ ;
use CGI::Carp qw/fatalsToBrowser/ ;

my $dataSource ;

db_connect() ;

print "Connected\n";

sub db_connect {
my $user = "name" ;
my $password = "password" ;
my $dataSource = DBIx::Simple->connect(
'dbi:Pg:database=prospects', $user, $password,
{ RaiseError => 1 , AutoCommit => 0 }
) or die DBI::Simple->error ;
}

If I run this from the command line "Connected" gets printed. If I run
it from a browser I get:

DBI connect('database=prospects','justin',...) failed: FATAL: Ident
authentication failed for user "justin" at
/var/www/inhouse/prospects/demo.cgi line 22

Does anyone know why this should be?

Thank you for your comments and suggestions.
--
Justin C, by the sea.
Paul Lalli

2007-06-27, 7:05 pm

On Jun 27, 9:40 am, Justin Catterall <jus...@masonsmusic.co.uk> wrote:
> I have the following code to connect to a database:


<snip>

> If I run this from the command line "Connected" gets printed. If I run
> it from a browser I get:
>
> DBI connect('database=prospects','justin',...) failed: FATAL: Ident
> authentication failed for user "justin" at
> /var/www/inhouse/prospects/demo.cgi line 22
>
> Does anyone know why this should be?


The user you're logged in as on the command line has access to the
database. The user your webserver is running as does not.

Fix the access permissions to your database.

See also:
$ perldoc -q 500
Found in /software/perl-5.8.5-0/pkg/lib/5.8.5/pod/perlfaq9.pod
My CGI script runs from the command line but not the
browser. (500 Server Error)


Paul Lalli

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com