I am having a problem changing the data directory on postgresql 9.2 on windows7:
i`m trying to change my data directory:
how can i change data directory on postgreSQL with pgAdmin?
I am having a problem changing the data directory on postgresql 9.2 on windows7:
i`m trying to change my data directory:
how can i change data directory on postgreSQL with pgAdmin?
This not possible from within pgAdmin (or any other SQL client because you need to stop the Postgres server in order to move the data directory)
To move the directory, use these steps:
Stop Postgres (you can use the control panel to find the correct service name)
net stop <name_of_the_service>
Remove the Windows service using
pg_ctl unregister -N <name_of_the_service>
re-create the service using (this assigns postgres
as the service name)
pg_ctl register -N postgres -D c:\new\path\to\datadir
start the service
net start postgres
run psql to verify that Postgres is up and running
psql -U postgres
Verify the running server is using the new data directory
show data_directory;
Details on how to use pg_ctl
can be found in the manual:
http://www.postgresql.org/docs/current/static/app-pg-ctl.html
Stop service by either opening services window and find postgresql-x64-xx (xx for verion number postgresql-x64-11, postgresql-x64-15 etc.) or using command line
sc stop postgresql-x64-11
run the following command is enough (no need to unregister) Replace "C:\postgre\data" with your new data location
sc config postgresql-x64-11 binPath= "\"C:\Program Files\PostgreSQL\11\bin\pg_ctl.exe\" runservice -N \"postgresql-x64-11\" -D \"C:\postgre\data\" -w"
start the service from services window or command line
sc start postgresql-x64-11