Jump to content

Default user in PostgreSQL


amal.barman

Recommended Posts

Hello,

I am accessing PostgreSQL from PHP pages. But to access the database, I need to create a super user in PostgreSQL database with name "apache" incase of LINUX and "SYSTEM" incase of WindowsXP operating system, otherwise I can not able to access to my database. Can anybody explain the reason or refer any markup? I am using LINUX+Apache+PostgreSQL+PHP5 and WindowsXP+Apache+PostgreSQL+PHP5 both.
...
$db=pg_connect($HOST,$DATABASE);
...

Thanks in advance.
Link to comment
Share on other sites

You should use this syntax instead:

[code=php:0]$dbconn = pg_connect("host=sheep port=5432 dbname=mary user=lamb password=foo");[/code]


Note that it allows you to specify the user and password.  There is no need to use "apache" or "SYSTEM" as the username.

See http://sg.php.net/manual/en/function.pg-connect.php
Link to comment
Share on other sites

Hello Jamest,

PostgreSQL does not allow anybody to connect without proper authenticity. Apache (incase of LINUX) or SYSTEM (incase of XP), may be two default user tries to connect the postgresql when connection made without any proper user information. This is not the problem of PHP anyway. 
Link to comment
Share on other sites

When you install PostgreSQL you associate the process with a user (typically the user postgres, but I guess in your case you used apache as your user?)

That's the account used when running processes, it gives the process local privileges to the computer.

When you create a database, you typically create a user in PostgreSQL that you would use to access the databases, set a password, and give them administrative access (if need be). (This user is separate from the system's users (whether it be a windows operating system or unix/linux)).

Then when you make a connection to the PostgreSQL database, you follow the syntax btherl posted, and include the user and password to connect to the database as.

The users and passwords to connect to a database are stored within the PostgreSQL process. The SYSTEM account in Windows and the apache (or postgres) account are not used when connecting to databases.


To create a user in PostgreSQL: [url=http://www.postgresql.org/docs/8.1/interactive/sql-createuser.html]http://www.postgresql.org/docs/8.1/interactive/sql-createuser.html[/url]
Follow btherl's syntax to establish the connection to the PostgreSQL database from PHP.

The user created can be of any name, it does not have to be "apache" or "SYSTEM", it can be anything.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.