DBIx::Simple, authentication fails

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I have the following code to connect to a database:


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.

Re: DBIx::Simple, authentication fails

Quoted text here. Click to load it


Quoted text here. Click to load it

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

Re: DBIx::Simple, authentication fails

Quoted text here. Click to load it

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


Justin Catterall                               www.masonsmusic.co.uk
Director                                       T: +44 (0)1424 427562
Masons Music Ltd                               F: +44 (0)1424 434362
                           For full company details see our web site

Site Timeline