Moving postgresql 9.4 data directory in fedora 22
I would like to know how to move the PostgreSQL database directory in a Fedora 22 installation. In Ubuntu, this is very straightforward by using pg_dropcluster
and sudo pg_createcluster -d /the/new/location/ 9.4 main
, but Fedora does not appear to have anything of the sort.
I copied the directory /var/lib/pgsql/data
to a new location and, did the following:
su - postgres
service postgresql stop
export PGDATA="/the/new/location/"
echo $PGDATA # gives the correct /the/new/location/
service postgresql start
psql
show data_directory;
Which still results in the default /var/lib/pgsql/data
...
Could someone please either provide a link to a relevant and up-to-date tutorial or explain how to complete the move?
Note: I am aware that this question has been answered for older versions of Fedora and Psql, but it seems a lot of the files have been moved about and none of the approaches seem to work for me.