Search code examples
postgresql

Postgres Database - Moving


I'm trying to move my postgres database from one location on disk to another (Windows 10, btw).

One of the first things I need to do is change postgresql.conf to set the data_directory variable. But when I go to that file I see:

The default values of these variables are driven from the -D command-line option or 
PGDATA environment variable, represented here as ConfigDir.

#data_directory = 'ConfigDir' # use data in another directory # (change requires restart)

So that's commented out. So I went to the command to start postgresql as a service, and by looking at its properties found that there's a parameter in there that sets the data directory:

"C:\Program Files\PostgreSQL\14\bin\pg_ctl.exe" runservice -N "postgresql-x64-14" -D "<this is the actual current path to the postgresql data directory>" -w

But it's only shown in a dialog in a field that I can't edit:

enter image description here

So how can I change that path to point it to the new data directory?


Solution

  • This seems to be related to modifying the path to the executable of a Windows service ,for which an answer is provided here.