PostgreSQL is pronounced as Post-gres-cue-el (Postgres-QL) and not Postgre-es-cue-el.
This chapter will help you to install and run the database very quickly in less than 5 minutes.
Quick Steps to Install, Test, Verify and run PostgreSQL Login as root.
# cd /mnt/cdrom/RedHat/RPMS # man rpm # ls postgre*.rpm # rpm -qpl postgre*.rpm | less (to see list of files) # rpm -qpi postgre*.rpm (to see info of package) # cat /etc/passwd | grep postgres
# rpm -i postgre*.rpm (Must install all packages clients, devel, data and main for pgaccess to work ) # man chkconfig # chkconfig --add postgresql (to start pg during booting) # /etc/rc.d/init.d/postgresql start (to start up postgres) # man xhost # xhost + (To give display access for pgaccess) # su - postgres bash$ man createdb bash$ createdb mydatabase bash$ man psql bash$ psql mydatabase ..... in psql press up/down arrow keys for history line editing or \s bash$ export DISPLAY=<hostname>:0.0 bash$ man pgaccess bash$ pgaccess mydatabase
bash$ cd /usr/doc/postgresql*
See also "Installation Steps" from http://www.ramifordistat.net/postgres
The maintainer of PostgreSQL RPMs is Lamar Owen and is at lamar.owen@wgcr.org More details about PostgreSQL is at http://www.postgresql.org
Familiarize with RedHat RPM package manager to manage the PostgreSQL installations. Download the 'Maximum RPM' textbook from http://www.RPM.org look for the filename maximum-rpm.ps.gz And read it on linux using the gv command -
# gv maximum-rpm.ps.gz
Examples are needed to do testing of various interfaces to PostgreSQL. Install the postgresql examples directory from -
Install examples package, see Examples RPM and then do -
bash$ cd /usr/lib/pgsql/python bash$ createdb thilo bash$ psql thilo thilo=> create table test (aa char(30), bb char(30) ); thilo=> \q bash$ /usr/bin/python >>> import _pg >>> db = _pg.connect('thilo', 'localhost') >>> db.query("INSERT INTO test VALUES ('ping', 'pong')") >>> db.query("SELECT * FROM test") eins|zwei ----+---- ping|pong (1 row) >>>CTRL+D bash$ ..... Seems to work - now install it properly bash$ su - root # cp /usr/lib/pgsql/python/_pg.so /usr/lib/python1.5/lib-dynload
Install examples package, see Examples RPM and then do -
root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/perl5 bash$ perl ./example.pl
bash$ perl -I/usr/lib/perl5/site_perl/5.005/i386-linux-thread ./example.pl
Read the example.pl file for using perl interface.
Install examples package, see Examples RPM and then do -
root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/libpq bash$ gcc testlibpq.c -I/usr/include/pgsql -lpq bash$ export PATH=$PATH:. bash$ a.out bash$ cd /var/lib/pgsql/examples/libpq++ bash$ g++ testlibpq0.cc -I/usr/include/pgsql -I/usr/include/pgsql/libpq++ -lpq++ -lpq -lcrypt bash$ ./a.out (Note: Ignore Error messages if you get any - as below) > create table foo (aa int, bb char(4)); No tuples returned... status = 1 Error returned: fe_setauthsvc: invalid name: , ignoring... > insert into foo values ('4535', 'vasu'); No tuples returned... status = 1 Error returned: fe_setauthsvc: invalid name: , ignoring... > select * from foo; aa |bb | -----|-----| 4535 |vasu | Query returned 1 row. > >CTRL+D bash$
Install examples package, see Examples RPM and also install the following -
root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/jdbc bash$ echo $CLASSPATH --> Should show CLASSPATH=/usr/lib/pgsql/jdbc7.0-1.2.jar:.:/home/java/jdk1.2.2/lib:/usr/lib/pgsql:/usr/lib/pgsql/classes.zip:/usr/lib/pgsql/pg.jar with proper jdbc*.jar version numbers. And the directories /usr/lib/pgsql and /usr/libjdk*/lib should contain *.jar files. bash$ export CLASSPATH=/usr/lib/pgsql/jdbc7.0-1.2.jar:.:/home/java/jdk1.2.2/lib:/usr/lib/pgsql:/usr/lib/pgsql/classes.zip:/usr/lib/pgsql/pg.jar Edit all psql.java file and comment out the 'package' line. bash$ javac psql.java bash$ java psql jdbc:postgresql:template1 postgres < password > [1] select * from pg_tables; tablename tableowner hasindexes hasrules pg_type postgres true false false pg_attribute postgres true false false [2] CTRL+C bash$
Install examples package, see Examples RPM and then do -
root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/ecpg bash$ ecpg test1.pgc -I/usr/include/pgsql bash$ cc test1.c -I/usr/include/pgsql -lecpg -lpq -lcrypt bash$ createdb mm bash$ ./a.out
Install examples package, see Examples RPM and then do -
root# chown -R postgres.postgres /var/lib/pgsql/examples bash$ cd /var/lib/pgsql/examples/sql Under-development..
Example of Tcl/Tk interfaces is pgaccess program. Read the file /usr/bin/pgaccess using an editor -
bash$ view /usr/bin/pgaccess bash$ export DISPLAY=<hostname of your machine>:0.0 bash$ createdb mydb bash$ pgaccess mydb
Get the RPMs from http://www.mutinybaysoftware.com
To verify the top quality of PostgreSQL, run the Regression test package :- Login as root -
# rpm -i postgresql*test.rpm And see README file or install the source code tree which has regress directory # rpm -i postgresql*.src.rpm # cd /usr/src/redhat/SPECS # more postgresql*.spec (to see what system RPM packages you need to install) # rpm -bp postgresql*.spec (.. this will prep the package) Regression test needs the Makefiles and some header files like *fmgr*.h which can be built by - # rpm --short-circuit -bc postgresql*.spec ( .. use short circuit to bypass!) Abort the build by CTRL+C, when you see 'make -C common SUBSYS.o' By this time configure is successful and all makefiles and headers are created. You do not need to proceed any further # cd /usr/src/redhat/BUILD # chown -R postgres postgresql* # su - postgres bash$ cd /usr/src/redhat/BUILD/postgresql-6.5.3/src/test/regress bash$ more README bash$ make clean; make all runtest bash$ more regress.out
Sometimes emergency bug fix patches are released after the GA release of PostgreSQL. You can apply these optional patches depending upon the needs of your application. Follow these steps to apply the patches - Change directory to postgresql source directory
# rpm -i postgresql*.src.rpm
# cd /usr/src/postgresql6.5.3
# man patch
# patch -p0 < patchfile
# make clean
# make
The patch files are located in