Skip site navigation (1) Skip section navigation (2)

Installing and configuring postgreSQL and ODBC on Red Hat Linux

From: Pavel Cenek <pavel(dot)cenek(at)itek(dot)norut(dot)no>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Installing and configuring postgreSQL and ODBC on Red Hat Linux
Date: 2002-02-12 09:57:25
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-odbc
     Hi everybody,

This document is NOT a question. I only want it to be placed in mailing list 
archives for postgreSQL beginners, who are facing the same problems as I did.

This text was written as part of the documentation to a project and I decided
to publish it, because it can help some other people to overcome some
obstacles during instalation and configuration Postgres and mainly ODBC on
Red Hat Linux. I had some problems and as I looked on web for solutions I
found out that many people had the same troubles before. But there were never
answers on the same place.

I don't claim that this description cowers all issues, is complete, correct
or useful for you.

If you find this text useful, please drop me a line (xcenek(at)fi(dot)muni(dot)cz).
It is nice to know that I helped you.


This document describes how I installed and configured postgreSQL and ODBC on
Red Hat Linux.

Written by: Pavel Cenek (xcenek(at)fi(dot)muni(dot)cz)

0. notes
I tried the installation on Red Hat Linux 7.1 with postgreSQL 7.1.3
Some tricks which are not documented on one place (or are not documented at
all) are written here. This file is not intended to replace postgreSQL
documentation. If you have any troubles RTMF (

Actually every rpm has version number connected to the name, I use names
without versions to refer to rpm files in the following text

1. installing and configuring postgreSQL
from or from a mirror site get from the section
"software" following rpms:

postgresql              client binaries, docs, man pages
postgresql-server       server binaries, some docs
postgresql-libs         shared libraries
postgresql-test         files for testing DB functionality
postgresql-devel        header files and developers libraries

    rpm -i <list of rpms>           for installing
    rpm -U <list of rpms>           for upgrade.

After installing we ensure that postgres will be started at startup of the
linux machine.

for every runlevel L on which you want postgres to be started (XY is a number)

If you want to access the DB via TCP/IP (i think ODBC does it this way, but I
can be wrong), do the folowing:
in file
add to line looking like this
    su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl  -D $PGDATA -p
/usr/bin/postmaster start  > /dev/null 2>&1" < /dev/null
parameters -o -i
    su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl  -D $PGDATA -o -i -p
/usr/bin/postmaster start  > /dev/null 2>&1" < /dev/null

The last thing to do is to set up access rights in file

    /etc/rc.d/init.d/postgresql start
to start the DB server.

You can go to the directory
and run tests of DB functionality (read README in that directory)

2. installing and configuring ODBC
from or from a mirror site get from the section
"software" following rpm:

postgresql-odbc       libraries and ini files

    rpm -i <rpm name>           for installing
    rpm -U <rmp name>           for upgrade.

    psql -d template1 -f /usr/share/pgsql/odbc.sql
to add some extra sql definitions to template1 table.

You are in the PostgreSQL interactive terminal.

    create type lo (
to add support for blobs accessible via ODBC to template1 table.

Quit the psql

Every created database inherits all definitions form template1, so you should
have all definitions in every DB you ever create.

3. installing and configuring iODBC Driver Manager
from get from the section "software download" iODBC
Driver Manager, i.e. following rpms:

libiodbc              iODBC Driver Manager Runtime Package (libraries,
                        config files)
libiodbc-devel        iODBC Developers Kit (odbc header files and developers

    rpm -i <list of rpms>           for installing
    rpm -U <list of rpms>           for upgrade.

Now we have to configure /etc/odbc.ini and and /etc/odbcinst.ini

if you use via ODBC only postgres, you can replace /etc/odbcinst.ini with
    cp /etc/pgsql/odbcinst.ini /etc/odbcinst.ini

Othervise you have to edit /etc/odbcinst.ini with use of information from

/etc/odbc.ini is special chapter... Be careful, this file is PARTIALLY case
sensitive. It means some attributes are, some are not.

If you have torubles with connection to postgres via ODBC, check if parameters
in your /etc/odbc.ini have the same case as in the following example:

------ /etc/odbc.ini file begin -----
;  odbc.ini
[ODBC Data Sources]
test = PostgreSQL Test

Description=Sample PostgreSQL DSN

Driver = /usr/lib/

InstallDir = /usr/lib/
------ /etc/odbc.ini file end -----

If you have done everything properly, the installation and setup is now

4. testing ODBC
With iODBC Driver Manager package should be distributed a small testing program
odbctest. I haven't found it, so I took its source directly from CVS and
compiled it myself.
This link worked fine for me:

gcc -c odbctest.c -o odbctest.o
gcc -s -o odbctest odbctest.o -liodbc

notice the -liodbc -- every program using odbc must be linked with iodbc
library. It is also not very well documented (at least I found it nowhere).

You can run the odbctest binary. If you run it without parameters, it asks
you for ODBC connect string. If you enter '?', it lists all dsn names (taken
from /etc/odbc.ini. Be careful, the right ODBC connect string is not "name",
but "dsn=name"!!!

If you have trubles, look into /home/gin2/odbc.trace
If you don't have troubles, continue reading

Congratulations, now everything should work fine :) I hope I saved you couple
of days, which I spent looking for these information.

pgsql-odbc by date

Next:From: Dave PageDate: 2002-02-12 10:26:19
Subject: Re: Installing and configuring postgreSQL and ODBC on Red
Previous:From: Jean-Michel POUREDate: 2002-02-12 09:02:07
Subject: Re: Unicode support

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group