0

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!

asked Nov 22, 2021 at 23:17

2 Answers 2

1

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.

answered Nov 23, 2021 at 8:27
0

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.

answered Nov 23, 2021 at 0:55
2
  • 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. Commented 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 output Commented Nov 23, 2021 at 6:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.