I'm following these instructions, however I can only get to step 17.2.
Despite installing postgresql successfully via the
sudo apt-get install postgresqlcommand, upon running
initdb -D /usr/local/pgsql/dataUbuntu tells me that it 'initdb' isn't installed. The instructions tell me this command is installed by
sudo apt-get install postgresqlso 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.
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.
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
passwd postgres- your passwordsu postgrespsql- Create a user with your user name like
CREATE USER SAM ; create database sam;- Log out and type
psql <your_user>