I installed postgresql from source on Ubuntu 14.0.4. It is located in
/usr/local/pgsql. At first, I created a data directory at
/usr/local/pgsql/data and then ran
initdb -D /usr/local/pgsql/data
I noticed inside this directory was a
Later I decided I wanted to put the data directory in the
/var directory, since it is variable data. So I created a directory at
/var/local/postgresql/9.4.2/main (I guess I should have named it data, but when using the repositories it uses main and I decided to follow that). Then I ran
initdb again but this time specifying a new data directory:
initdb -D /var/local/postgresql/9.4.2/main
And pretty much it created the same data files as it did before, including the
postgresql.conf. This time I opened up the
/var/local/postgresql/9.4.2/main and gave it a default data directory:
data_directory = '/var/local/postgresql/9.4.2/main'
Now, at this point I wanted to start the postmaster daemon but I want the daemon to read the data directory from
/var/local/postgresql/9.4.2/main rather than me specifying it as a flag. Unfortunately, it doesn't work:
$ pg_ctl start pg_ctl: no database directory specified and environment variable PGDATA unset Try "pg_ctl --help" for more information.
How can I get this to work?