This chapter will help you to install and run the database very quickly in less than 10 minutes.
Quick Steps to Install, Test, Verify and run PostgreSQL Login as root.
# rpm -qpl postgre*.rpm (to see list of files. For docs 'man rpm') # 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 )
# chkconfig --add postgresql (to start pg during booting, see 'man
chkconfig')
# cp /usr/lib/pgsql/python/_pg.so /usr/lib/python1.5/lib-dynload (for
python)
# /etc/rc.d/init.d/postgresql start (to start up postgres)
# su - postgres
bash$ createdb mydatabase (this will create a database by name
'mydatabase')
(for doc 'man createdb')
bash$ psql mydatabase (for doc 'man psql')
..... in psql press up/down arrow keys for history line editing or \s
bash$ export DISPLAY=<hostname>:0.0; pgaccess mydatabase; (see 'man
pgaccess')
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
Download the 'Maximum RPM' textbook from http://www.RPM.org the filename is maximum-rpm.ps.gz And read it on linux using gv command -
# gv maximum-rpm.ps.gz
bash$ cd /usr/lib/pgsql/python
bash$ createdb thilo
bash$ psql thilo
thilo=> create table test (aa char(30), bb char(30) );
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$
..... Yow! Seems to work - now install it properly
bash$ su - root
# cp /usr/lib/pgsql/python/_pg.so /usr/lib/python1.5/lib-dynload
bash$ cd /usr/doc/postgresql-6.5.3/examples/perl5
bash$ perl -I/usr/lib/perl5/site_perl/5.004/i386-linux-thread ./example.newstyle
Read the example files for using perl interface
bash$ cd /usr/doc/postgresql-6.5.3/examples/libpq++
bash$ su root --> to change ownership of examples
# chown -R postgres /usr/doc/postgresql-6.5.3/examples
# exit
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$
For this you MUST install the jdk-*glibc*.rpm package (Java RPM packages)
bash$ cd /usr/doc/postgresql-6.5.3/examples/jdbc bash$ echo $CLASSPATH --> Should show CLASSPATH=/usr/lib/jdk-1.1.6/lib/classes.zip bash$ export CLASSPATH=$CLASSPATH:.:/usr/lib/pgsql/postgresql.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$
bash$ cd /usr/doc/postgresql-6.5.3/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
bash$ cd /usr/doc/postgresql-6.5.3/examples/sql Under-development..
Example of Tcl/Tk interfaces is pgaccess program. Read the file /usr/bin/pgaccess using a 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*.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