sudo -u postgres psql
After opening the PostgreSQL prompt, use the following command to display the current data directory:
SHOW data_directory; data_directory ------------------------------ /var/lib/pgsql/9.6/data (1 row)
This output is confirmed PostgreSQL is configured to use the default data directory, that is /var/lib/postgresql/10/main
, so this is we need to move the directory. After confirming the directory on the system, type \q
and press ENTER
to close the PostgreSQL prompt.
To ensure data integrity, stop PostgreSQL before actually change the data directory:
sudo rsync -of / was / lib / pgsql / tmp / pgsql
/var/lib/pgsql/9.6/data