Dirk Dot Net

Creator of useful things. Based in Chiang Mai, Northern Thailand.

Installing PostgreSQL 8.3 on Linux Mint/Ubuntu, Some Tips

del.icio.us Tags: PostgreSQL 8.3, Linux, Install

Update: The below instructions are outdated as it's now much easier and safer to install a now stable backport package for PostgreSQL-8.3. To learn more about backports, visit this page and enable the backport repository for your Linux distribution. You can then install via the package manager or apt-get. Or just try ** sudo apt-get -t sarge-backports install postgresql-8.3** The latest version of PostgreSQL can't yet be installed on Ubuntu (Linux Mint) via apt-get install of a mature Debian package, so the process is a little more involved and somewhat challenging for a Linux newbie such as I. Here are some hints: The article 10 Steps to Installing PostgreSQL is very helpful and mandatory if you're not that familiar with installing packages manually on Linux. Then this forum post has some additional hints and is geared towards 8.3. So here are my ten steps:

  1. Do a sudo apt-get install build-essential which really is essential for installing source packages.
  2. Download libxml sources which you have to install as the installation on Gutsy Gibbon is faulty (see the "forum post" quoted above for details), so from your download dir sudo mv libxml2-sources-2.6.31.tar.gz /usr/local/src
    cd /usr/local/src
    sudo tar -xzvf libxml2-sources-2.6.31.tar.gz
    cd libxml2-2.6.31
    sudo make install
  3. Download a postgresql-8.3.0.tar.gz from a mirror listed here.
  4. Then from your download directory sudo mv postgresql-8.3.0.tar.gz /usr/local/src
    cd /usr/local/src
    sudo tar -xzvf postgresql-8.3.0.tar.gz For an explanation see the "10 Steps" article.
  5. Configure and install PostgreSQL: cd /usr/local/src/postgres-8.3.0
    ./configure --with-libxml --without-readline --without-zlib --with-libraries=/usr/local/lib
    sudo make install Hopefully you'll get a "PostgreSQL installation complete."
  6. Do user related stuff: #create the postgres user sudo adduser postgres sudo mkdir /usr/local/pgsql/data sudo chown postgres /usr/local/pgsql/data
  7. Change to the postgres user and continue #change to the postgres user sudo su - postgres
  8. The rest is verbatim from the forum post: #initialize the data directory /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data cd /usr/local/pgsql/data#create the log dir mkdir log #sample to start the server /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >/usr/local/pgsql/data/log/logfile 2>&1 & #create a sample database /usr/local/pgsql/bin/createdb mysampledb #now test it /usr/local/pgsql/bin/psql mysampledb
    You're all set and the database server should be running.
  9. You might wanna create a new password for the postgres user: sudo passwd postgres
  10. Then you can connect with pgAdmin III File > Add Server
    address: localhost
    Description: my beautiful server or whatever
    Password: do you remember?
    Click OK
  11. OK, these go to 11:To start the server automatically at every boot, simply add: su -c '/usr/local/pgsql/bin/pg_ctl start -l /usr/local/pgsql/data/log/logfile -D /usr/local/pgsql/data' postgres to your /etc/rc.local file. More info is here. Hope it helps.


horaciod: I'm getting an error in compile postgresql time . wich Libraries that are needed to build support for multibyte (utf8 ) ?

dirk: @horaciod, which errors are you getting? As for utf8-support, there used to be an --enable-multibyte and a --enable-unicode option quoted in the "10 Steps" article. I'm not sure if this is still necessary with the latest versions. I have the server running with full unicode support without any extra install options besides the ones quoted but your mileage may vary.

Roman G.: For me postgres 8.3 was installed by apt-get. The problem was the placement of pg_ctl file,and other files of postgres installation it was not in PATH for postgres, that's why I experienced the problem in stopping it. I am going to downgrade to 8.2 until it will be fixed.

aampal: Hi, Thank so much for the blog............ I did this this everything is working fine excepth xpath_tabale and a few other functions are not working or not found i think i misssed something in that installation... could You please e-mail me a reply.... i'm on this for a few days... Please help me

dirk: @aampal: The instructions are now largely outdated as you can just install from a backport via apt-get for example by just typing sudo apt-get -t sarge-backports install postgresql-8.3 This will install everything for you.

igune kriss: hi, ive been using this tutorial to install postgresql and all was well until i arrived at the server starting command, i managed to bypass this error: $/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data LOG: could not bind IPv6 socket: Address already in use HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. LOG: could not bind IPv4 socket: Address already in use HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry. WARNING: could not create listen socket for "localhost" FATAL: could not create any TCP/IP sockets by using: $/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start so i proceed then this comes up: $/usr/local/pgsql/bin/createdb mysampledb createdb: could not connect to database postgres: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? . i do not know where to go next. i have LAMP already running and i want to use both mysql and postgres database concurently since i have to test sevral projects thus requiring both evry now and then. anyone with a handy solution?