By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

What user are PHP database queries executed as?

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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/passwd 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 assign a login name and password to
access that database. When you connect to the database you pass the login
name and password 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 password=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 password 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/
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.