> Programming Languages > PHP
Various Topics Home | Disclaimer | Report Adult Posts

Various Topics on PHP



PHP - "What user are PHP database queries executed as?" in Programming Languages


Old 06-21-2004   #1
..ab..
 
Default What user are PHP database queries executed as?

I have an installation of Apache that apparently includes PHP (out of
the box Redhat 9.0).

If I make database calls to Postgresql, as what user is that call
going to be made? The user that Apache is running as? Can I specify
the user that the call is to be made as?

Thanks,
--Ulf
 
Old 06-21-2004   #2
..r.. ....
 
Default Re: What user are PHP database queries executed as?

arabub wrote:

> If I make database calls to Postgresql, as what user is that call
> going to be made? The user that Apache is running as? Can I specify
> the user that the call is to be made as?


There are two different types of users here

1) The user that the Postgresql database server runs as. This is a system
user as defined in the /etc/p***wd file.

2) The database user that you connect to the database as. This is a database
defined user, and it not the same as the type of user in (1).

When you create a new database you can ***ign a login name and p***word to
access that database. When you connect to the database you p*** the login
name and p***word as defined in the database to connect to a specific
database.

This example is from the PHP manual (www.php.net/pg-connect):
pg_connect("dbname=mary user=lamb p***word=foo");

In this example you are connecting to a database called "mary" as the user
"lamb". That user is who you are connecting to Postgresql as, and is a
database defined user, not a system defined one.

If you do not specify a login name and p***word that has already been set up
in Postgres then you won't be able to connect.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0