https://stackoverflow.com/questions/22596301/how-to-change-postgresql-data-directory
(Note: for Linux be aware the drive mounting will need to allow the postgres user to access it... so even if the folder has chown -R postgres:postgres /mnt/datadrive/pgdb if the /mnt/data drive doesn't allow the postgres user then it won't work.. so run sudo chmod 777 /mnt/datadrive first. For other folders use chmod 700 -Rv /mnt/datadrive/pgdata and chown postgres:postgres -Rv /mnt/datadrive/pgdata)
To move the directory, use these steps:
- Stop Postgres (you can use the control panel to find the correct service name)
net stop
- Make sure Postgres is not running (e.g. using ProcessMonitor)
- Remove the Windows service using
pg_ctl unregister -N
- make sure Postgres is not running
- move the data directory to the new location (or maybe only copy it, so that you have a backup)
- 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
No comments:
Post a Comment