What user are PHP database queries executed as?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • arabub

    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
  • Chris Hope

    #2
    Re: What user are PHP database queries executed as?

    arabub wrote:
    [color=blue]
    > 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?[/color]

    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("dbn ame=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/

    Comment

    Working...