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. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 4 down vote accepted

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

What version of Postgresql are you using? You show a link to 8.3 which is many years old. These docs are current:

Did you install Postgresql with an up-to-date package, a la ?

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

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 precise-pgdg main" > "$PG_REPO_APT_SOURCE"

  # Add PGDG repo key:
  wget --quiet -O - | 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 "postgresql-${PG_VERSION}"

# (Optional) Install PostgreSQL Contrib Modules
apt-get install "postgresql-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

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.