Click here to get back home

DBIx::Simple, authentication fails

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
DBIx::Simple, authentication fails Justin Catterall 06-27-2007
Posted by Justin Catterall on June 27, 2007, 9:40 am
Please log in for more thread options

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.

Posted by Paul Lalli on June 27, 2007, 10:41 am
Please log in for more thread options
> 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


Posted by Justin C on June 27, 2007, 11:32 am
Please log in for more thread options
>> 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)

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

        Justin.

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

Similar ThreadsPosted
DBIx::Simple, fails with no error (not CGI this time!) June 28, 2007, 10:15 am
DBIx::Simple variable interpolation problem July 6, 2007, 6:29 am
parsing from secure apache site. simple authentication November 21, 2006, 12:57 pm
[newbie] XML::Simple install fails? June 4, 2007, 7:54 am
Re: DBIx::XML::DataLoader April 24, 2008, 3:25 am
DBD::pg suitable version for DBIx::Textindex 0.25 March 12, 2006, 11:20 pm
using DBIx::Class with native SQL query?? April 20, 2006, 5:19 am
[newbie]How to call stored procedure using DBIx? December 28, 2007, 8:19 am
Constant.t fails 240 of 272 tests and recurs.t fails 1 of 25 tests on HPUX using perl 5.8.7 December 8, 2005, 9:16 am
LWP authentication on asp page March 23, 2005, 10:32 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap