Install postgresql. Why is initdb unavailable?

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?

4 Answers

You will find initdb under /usr/lib/postgresql/x.y/bin/. See also /usr/share/doc/postgresql-common/README.Debian.gz for more information on the setup on Debian and Ubuntu.

5

initdb is intended to be run under the postgres user account that is created during the install. After installing postgresql you can do:

sudo su - postgres

Then you should be able to run initdb.

4

initdb is not installed as user executable. Is only installed in /usr/lib/postgresql/X.X/bin/, because it always depends on the version. initdb can only be executed from that specific directory.

As mentioned in other answers, installation of postgres creates a default directory that may be in a limited partition. Users may want to change this, but it requires other steps also. see here.

Follow the following steps with user root

  1. passwd postgres - your password
  2. su postgres
  3. psql
  4. Create a user with your user name like CREATE USER SAM ;
  5. create database sam;
  6. Log out and type psql <your_user>
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like