Showing posts with label postgresql. Show all posts
Showing posts with label postgresql. Show all posts

5/19/2010

How to grant select privileges to all tables in database in PostgreSQL

After a couple of research, I figured out the command that grants select privileges to all tables of the database in PostgreSQL.

 select 'grant select on '||schemaname||'.'||tablename||' to username;' from pg_tables where schemana
me in ('public');

Also in the case of views it would be the following.

 select 'grant select on '||schemaname||'.'||viewname||' to username;' from pg_views where schemaname
 in ('public');

You'll get the list of SQL statements to grant all tables the privileges you want like following.

                          ?column?
------------------------------------------------------------
 grant select on public.table_a to username;
 grant select on public.table_s to username;
 grant select on public.table_d to username;
 grant select on public.table_f to username;
 grant select on public.table_g to username;
........

(xx rows)

Then, excute those SQL statements.
That's it.:)

I referred the following post.
http://bensbrain.blogspot.com/2004/08/postgres-grant-on-all-tables-in.html 

10/19/2009

Redmine + PostgreSQL installation notes.

PostgreSQL install
==================
yum install postgresql postgresql-devel postgresql-server postgresql-contrib

userdel postgres
To change home directory for postgres user from /var/lib/postgres to /home/postgres

useradd postgres
passwd postgres

mkdir /usr/local/pgsql
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su postgres
initdb -D /usr/local/pgsql/data -E utf-8

su - postgres
vi .bash_profile
add the following lines and save.
###
export PATH="$PATH":/usr/local/pgsql/bin
export POSTGRES_HOME=/usr/local/pgsql
export PGLIB=$POSTGRES_HOME/lib
export PGDATA=$POSTGRES_HOME/data
export MANPATH="$MANPATH":$POSTGRES_HOME/man
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":"$PGLIB"
###

pg_ctl -D /usr/local/pgsql/data -l logfile start

psql -e
postgres=# CREATE DATABASE redmine;
postgres=# \c redmine;
postgres=# ALTER DATABASE "redmine_db" SET datestyle="ISO,MDY";


Redmine install
===============

Ruby
====
yum install ruby ruby-devel ruby-irb ruby-rdoc ruby-ri

Rubygems
========
wget http://rubyforge.iasi.roedu.net/files/rubygems/rubygems-1.3.4.tgz
tar xzvf rubygems-1.3.4.tgz
cd rubygems-1.3.4
ruby setup.rb
gem --version

Ruby on Rails
=============
gem install rails


useradd redmine
passwd redmine
su - redmine

wget http://rubyforge.org/frs/download.php/63583/redmine-0.8.5.tar.gz
tar xvfz redmine-0.8.5.tar.gz
cd redmine-0.8.5

/home/redmine/redmine-0.8.5/config
cp database.yml.example database.yml
vi database.yml
Edit the file like following and save.
###
production:
adapter: postgresql
database: redmine
host: localhost
username: postgres
password: anything_you_like
encoding: utf8
###

gem install postgres-pr
cd /home/redmine/redmine-0.8.5
rake db:migrate RAILS_ENV="production" &

That's it!!