DBIx::Simple, authentication fails

J

Justin Catterall

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.
 
P

Paul Lalli

I have the following code to connect to a database:

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
 
J

Justin C

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)

Thank you Paul, adding www-data to the list of database users fixed
this.

Justin.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top