Postgresql Setup

Postgresql Setup


Author: Wade, Hampton
Email: whampton@staffnet.com

System Architecture: All/General
RedHat Release: RHL 5.2
FAQ Category: Application Notes
Modification Date: Nov 24, 1998

Question:

How do I get postgres to work?  Is there a GUI for the database?

Answer:

Postgresql is a very flexible, mostly SQL compliant database that
comes with RedHat 5.x.  This database includes a GUI, access control,
support for large objects (BLOBS), and WWW support (java, ODBC,
and PHP).  

To get postgres to work you have to allow access to hosts,
then allow users to access the database system.  

1) Setup host-based access
      cd /var/lib/pgsql
      edit pg_hba.conf
        read the examples and allow localhost and others to access the dbs.
        for localhost and to trust everybody:
          local all  trust
        for network access
          host all 127.0.0.1 255.255.255.255 trust
      READ THE EXAMPLES!

2) To allow access from external hosts (and PHP via the localhost):
      cd /etc/rc.d/init.d
      edit postgresql
        where postmaster is started, add the command line option "-i".
           su postgres -c '/usr/bin/postmaster -i -S ....

3) Allow users to access the database, including creating databases, etc.
      createuser <username>
         prompt for the User's ID (enter to accept the provided one).
         prompt for if they are allowed to create databases (Y/N)
         prompt for if they are allowed to add users (Y/N)

4) To create a database
      as a user allowed to create databases:
          createdb dbname

5) To access the GUI and add tables, etc.:
      as a user allowed access to the database (and with X running):
          pgaccess dbname &

6) To access this database from the command line:
      psql dbname  OR pgsql dbname <file_with_sql

7) To allow others to access this database, use the "grant", e.g.,
      psql dbname
      grant SELECT on table1 to public;
      
I hope this quickstart helps -- for more info, see the Postgres docs
and manual pages!

References:

http://www.postgresql.org
http://www.php.org
manual pages for postgresql