Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I'm following these instructions, however I can only get to step 17.2.

Despite installing postgresql successfully via the

sudo apt-get install postgresql

command, upon running

initdb -D /usr/local/pgsql/data

Ubuntu tells me that it 'initdb' isn't installed. The instructions tell me this command is installed by

sudo apt-get install postgresql

so what's going on? I can make initdb available by installing postgres-xc, but I think postgres-xc is just some weird third party rubbish, and it's not detailed in the instructions. Any ideas?

share|improve this question
You may want to have a look at wiki.postgresql.org/wiki/… –  dezso Nov 5 '13 at 22:15
If you installed Postgres-XC then wy are you looking at the manual of a non-supported regular Postgres version? –  a_horse_with_no_name Nov 7 '13 at 21:09
The instructions of the PG manual are essentially distribution-independant. It never says to run sudo apt-get install postgresql to begin with, because that only applies to Debian-based distros, Ubuntu being one of them. –  Daniel Vérité Nov 8 '13 at 15:54
The starting point for PG on Ubuntu is here: help.ubuntu.com/community/PostgreSQL . It doesn't mention initdb because you don't have to call it, it's done for you by the Ubuntu install scripts that the official PG doc doesn't know or care about. –  Daniel Vérité Nov 8 '13 at 16:03

3 Answers 3

up vote 1 down vote accepted

If you haven't set up the environment variables, then you need to specify the full path to your executables.

Postgres-XC hardly qualifies as "weird third party rubbish", it is a distributed fork of Postgres. http://sourceforge.net/apps/mediawiki/postgres-xc/index.php?title=Main_Page

What version of Postgresql are you using? You show a link to 8.3 which is many years old. These docs are current: http://www.postgresql.org/docs/current/static/creating-cluster.html

Did you install Postgresql with an up-to-date package, a la http://www.postgresql.org/download/linux/ubuntu/ ?

When installing 9.2 on Ubuntu, I added the following lines to the ~postgres/.bash_profile

export PATH=/usr/lib/postgresql/9.2/bin:$PATH:/usr/sbin
export PGDATA=/var/lib/postgresql/9.2/main
export PGPORT=5432

Where "/usr/lib/postgresql/9.2/bin" is the path to your 9.2 executables. That made the installation a bit smoother for me.

share|improve this answer
can't get over how impossible this is to install.. –  Starkers Nov 5 '13 at 22:21
Thanks for the updated docs, but they appear to be identical up to the point I'm talking about. I did install the latest package. Really don't know why this is so hard. –  Starkers Nov 5 '13 at 22:23
I rarely install on Ubuntu, but as I recall it was fairly straightforward if the env vars were set. There were a few more hoops to jump through than installing on CentOS IIRC. –  bma Nov 5 '13 at 22:40
Oh for god's sake, I've just followed every damn word in postgresql.org/docs/current/static/creating-cluster.html , compiled from the source code and still initdb is currently not installed! It says in the documentation that initdb is installed when you install postgresql! PostgreSQL installation complete. That's what the install told me. What is going on? Why is noone else having this trouble? –  Starkers Nov 6 '13 at 0:42
After sudo updatedb, does locate initdb return something? –  dezso Nov 6 '13 at 5:47

The instructions you link to are out of date. They are for version 8.3 which is no longer supported. As of the time of writing this the oldest supported version is 8.4.

Although even 8.4 is still supported, if you're doing a new install it's recommended that you install a newer version. The standard Ubuntu 12.04 repositories currently have PostgreSQL version 9.1. An alternative (listed below) is to use the PGDG APT repositories. They're more up to date and allow you to also install 9.2 or 9.3 (the latest stable release as of the time of writing this).

Installing PostgreSQL on Ubuntu is really easy. The instructions below install PostgreSQL 9.3. To install a different version, just change the PG_VERSION variable name to the version you'd like to install.

Also listed below is how to install the contrib module which allows you to install a lot of the more popular extensions (like hstore) via CREATE EXTENSION ....

# Retrieve and install the GPG key PGDG:
if [ ! -f "$PG_REPO_APT_SOURCE" ]
  # Add PG apt repo:
  echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > "$PG_REPO_APT_SOURCE"

  # Add PGDG repo key:
  wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | apt-key add -

# Update your package lists
apt-get update

# Edit this to the version you'd like to install, e.g. 8.4, 9.0, 9.1, 9.2, or 9.3

# Install PostgreSQL
apt-get install "postgresq-${PG_VERSION}"

# (Optional) Install PostgreSQL Contrib Modules
apt-get install "postgresq-contrib-${PG_VERSION}"

Note that you don't need to do anything special like run initdb manually after installing it this way. That will all be done for you by the installer.

share|improve this answer

Please note that there are typos in the instructions. The install lines are missing an 'l' in two places (postgresql instead of postgresq). So the last two commands should be:

# Install PostgreSQL
apt-get install "postgresql-${PG_VERSION}"
# (Optional) Install PostgreSQL Contrib Modules
apt-get install "postgresql-contrib-${PG_VERSION}"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.