[Wolves] (Covide) More help pls

James Turner james at turnersoft.co.uk
Sun Aug 20 02:08:02 BST 2006


On Thursday 17 August 2006 22:21, Adam Sweet wrote:
> Peter Cannon wrote:
> > On Thursday 17 August 2006 17:18, Peter Cannon wrote:
> >
> > Boo! Close but no cigar :(
> >
> > I've just finished doing all the configuration did 'localhost' and voila
> > got a lovely login screen, chuffed to bits entered the user name and
> > password I chose, hit enter and...........
> >
> > Warning: pg_query() [function.pg-query]: Query failed: ERROR: permission
> > denied for relation gebruikers in /var/www/common/functions_postres.php
> > on line 147 SQL error.
> >
> > I had a look
> >
> > Line 147 $result = pg_query ($db, $q);
> >
> > I don't know this stuff so I'm stumped for the minute any ideas my mate
> > Aq?
>
> This is a postgresql permissions error. Does your apache user have read
> permissions on that db?

The permissions needed will depend on what the query does (whatever is in 
variable $q). The connection to the database will have been previously 
established with pg_connect(), supplying a user name and password to access 
the database. To set this up:

 - If necessary, set authentication mechanisms to be used by editing
   pg_hba.conf and/or pg_ident.conf.

 - If either of the config files were edited, get PostgreSQL to
   re-read them using "killall -HUP postmaster" (or
   "pg_ctl reload -D <database-directory>").

 - You can then grant the necessary permissions to tables and databases via
   the "psql" or "createuser" commands.

Until the permissions are fully set up, you may need to use "su <user>" to 
switch to the user under which PostgreSQL is running in order to run admin 
commands. Example:

[root at piglet db]# su postgres
bash-3.00$ psql -d stupid_db
Welcome to psql 8.0.8, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
       \h for help with SQL commands
       \? for help with psql commands
       \g or terminate with semicolon to execute query
       \q to quit

stupid_db=# create user foolish_user encrypted password 'password' nocreatedb 
nocreateuser;
CREATE USER
stupid_db=# alter table idiotic_table owner to database_admin;
ALTER TABLE
stupid_db=# grant select on table idiotic_table to foolish_user;
GRANT
stupid_db=# \q
bash-3.00$

Example using "createuser" method:

[root at piglet db]# su postgres
bash-3.00$ createuser foolish_user -P
Enter password for new user:
Enter it again:
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
bash-3.00$ 

If you prefer a graphical interface to PostgreSQL administration, I quite like 
pgadmin (http://www.pgadmin.org/).

Regards,

James



More information about the Wolves mailing list