Created
April 22, 2014 14:05
-
-
Save justingarrick/11180527 to your computer and use it in GitHub Desktop.
Use PostgreSQL on OS X VM Host via Parallels Windows VM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This assumes Postgres is installed via Postgres.app | |
1) Setup a PGDATA environment variable in ~/.zshrc, e.g. | |
### PostgreSQL data | |
export PGDATA="/Users/justingarrick/Library/Application Support/Postgres/var-9.3" | |
2) In $PGDATA/postgresql.conf, add | |
listen_addresses = '*' | |
3) In $PGDATA/pg_hba.conf, add | |
# Allow access from Windows VM | |
host all all 0.0.0.0/0 md5 | |
4) In Parallels, go to Preferences > Advanced > Click the Change Settings... button next to Network > Shared > Show in System Preferences | |
5) In OS X, find the Parallels Shared connection under System Preferences > Network, copy the IP Address, e.g. 10.211.55.2 | |
6) In the Windows VM, edit the hosts file, e.g. C:\Windows\System32\drivers\etc\hosts, add an entry for this IP, e.g. | |
10.211.55.2 vmhost | |
7) In the Windows VM, add inbound and outbound firewall rules to allow TCP port 5432 | |
8) Restart the Windows VM | |
9) In OS X, restart Postgres, e.g. | |
$pg_ctl restart | |
10) Add a connection to vmhost:5432 in PGAdmin on the Windows VM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for step 3, it didn't work for me. Eventually I need to put the VM ip instead. To get the VM IP, fire
ipconfig
in command prompt/powershell and you shall see it. Then add the ip to pg_hba.conf.Step 4, 5 and 6 are not absolutely necessary. However, we do need to get the host ip. To get your host IP, do
ifconfig
in OS X terminal and look for something as below:The rest of the steps do work. I was able to connect to OS X postgres from windows PgAdmin and Powerbi database connector.
A side note, make sure
npgsql
was installed (with GAC feature) if you are connecting to postgresql via dot net application.