amal.barman Posted November 11, 2006 Share Posted November 11, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/26929-default-user-in-postgresql/ Share on other sites More sharing options...
btherl Posted November 13, 2006 Share Posted November 13, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/26929-default-user-in-postgresql/#findComment-123824 Share on other sites More sharing options...
jamest Posted November 13, 2006 Share Posted November 13, 2006 Are you able to connect to postgreSQL directly (not using PHP) without having to use a super user or is this just a problem when using PHP? Quote Link to comment https://forums.phpfreaks.com/topic/26929-default-user-in-postgresql/#findComment-123902 Share on other sites More sharing options...
amal.barman Posted November 14, 2006 Author Share Posted November 14, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/26929-default-user-in-postgresql/#findComment-124552 Share on other sites More sharing options...
remmargorp Posted November 15, 2006 Share Posted November 15, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/26929-default-user-in-postgresql/#findComment-124993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.