Re: Postgresql newbie username/password question

From: will trillich <will(at)serensoft(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql newbie username/password question
Date: 2001-05-11 21:18:38
Message-ID: 20010511161838.B18098@serensoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 09, 2001 at 01:58:10AM -0700, Gary wrote:
> I've just installed v7.1 and got the DBD stuff working so I'm able to
> connect to a test database and return data within a perl script.
>
> I'm slightly confused how the concept of user authentication works in
> Postgresql. I ideally need to have a specific user to connect to a
> database from the web, how do I pass this detail through the DBD, I
> don't see an option in the connect string. I was using Oracle and you
> could specify user and password details to the connect string okay ? Am
> I missing something obvious ?

probably.

presuming you're talking about DBD::Pg for perl (used via DBI):

% man DBD::Pg

The following connect statement shows all possible
parameters:

$dbh = DBI->connect("dbi:Pg:dbname=$dbname;host=$host;port=$port;options=$options;tty=$tty", "$username", "$password");

If a parameter is undefined PostgreSQL first looks for
specific environment variables and then it uses hard
coded defaults:

parameter environment variable hard coded default
--------------------------------------------------
dbname PGDATABASE current userid
host PGHOST localhost
port PGPORT 5432
options PGOPTIONS ""
tty PGTTY ""
username PGUSER current userid
password PGPASSWORD ""

so if you authenticate somehow and get a $username you'll also need the
matching $password to use like so--

my $DSN = "dbi:Pg:dbname=$database";
$dbh = DBI->connect($DSN,$username,$password);

before then, of course, you'll need to establish postgresql awareness of the
various users you're interested in having log in (from the web server machine,
which may be localhost) and connect.

--
don't visit this page. it's bad for you. take my expert word for it.
http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html

will(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!

In response to

Browse pgsql-general by date

  From Date Subject
Next Message will trillich 2001-05-11 21:26:39 Re: single quotes in a select statement
Previous Message will trillich 2001-05-11 21:13:33 Re: Format of timestamp field