note 33195 modified in ref.pgsql by pollita

From: Date: Wed, 18 Jun 2003 21:50:55 +0000
Subject: note 33195 modified in ref.pgsql by pollita
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-50604@lists.php.net to get a copy of this message
In debian, for example, Apache/PHP runs as www-data, so to access postgreSQL databases and tables: 1. You need to add www-data as PostgreSQL user and use quotes around "www-data": $ su # su - postgres $ createuser "www-data" Shall the new user be allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n CREATE USER $exit #exit $ 2. Since you're not logging on as "www-data", creating databases and tables, you need to grant access to tables you create to www-data: $ psql mydb Welcome to psql 7.3.3, the PostgreSQL interactive terminal. mydb=> grant all on <tablename> to "www-data"; GRANT --was-- Debian hint: In debian, Apache/PHP runs as www-data, so to access postgreSQL databases and tables: 1. You need to add www-data as PostgreSQL user and use quotes around "www-data": $ su # su - postgres $ createuser "www-data" Shall the new user be allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n CREATE USER $exit #exit $ 2. Since you're not logging on as "www-data", creating databases and tables, you need to grant access to tables you create to www-data: $ psql mydb Welcome to psql 7.3.3, the PostgreSQL interactive terminal. Type: \copyright for distribution terms \h for help with SQL commands \? for help on internal slash commands \g or terminate with semicolon to execute query \q to quit mydb=> grant all on <tablename> to "www-data"; GRANT http://www.php.net/manual/en/ref.pgsql.php

« previous php.notes (#50604) next »