I set up PostgreSQL on my mac and I am trying to share the database files through GitHub to my Windows machine and other users.
I know how to start the PostgreSQL Service from a specific data directory, through the CLI, on my mac but I cannot seem to find how to change the data directory on Windows.
I have been using pgAdmin on windows but I haven't been able to find anything for just starting the service from a different data directory. I feel like this should be an easy thing, but just can't find it anyewhere.
Thank you for any help!
2 Answers 2
The whole idea is wrong. PostgreSQL is a client-server system, and you never share the data directory. The only one who has access is the PostgreSQL server process. The client connects to the server, which reads and writes data in the data directory.
If you somehow manage to start two different postmaster processes on the same PostgreSQL data directory, the result will be data corruption.
You can stop the server and start with new data directory, go inside bin folder where Postgres is installed and run following command in command prompt:
pg_ctl.exe stop -D "<path to current data>"
pg_ctl.exe start -D "<path to New data>"
Note: I'm not sure whether you can use Linux/Unix(Mac) initiated data directory on windows.
-
Ah, yea I don't think I can share the database in that way it doesn't like that it wasn't made by a windows machine. Do you know of a way I can share the database files across systems without using a server? I would like to use github and be able to update a directory in my git repo and then update the local database based on that.Hmkyriacou– Hmkyriacou2021年11月23日 01:27:49 +00:00Commented Nov 23, 2021 at 1:27
-
2@Hmkyriacou: "I can share the database files across systems without using a server?" not possible. The only thing you can safely upload to github is a
pg_dump
outputuser1822– user18222021年11月23日 06:46:28 +00:00Commented Nov 23, 2021 at 6:46