PostgreSQL Cookbook
Installation on Windows
Search for the "PostgreSQL Windows". There is an installer available. It's pretty straightforward.
Creating a database
Use the pgAdmin III program.
- First create a Login Role for the database. Set the database's owner to the new (or existing) login role:
Object browser > Server Groups > [server] > Login Roles > (right click) > New Login Role - Create the database
Object browser > Server Groups > [server] > Databases > (right click) > New Database
Restarting the server
The PostgreSQL service name includes the version number.
With powershell run with Administrator privileges, navigate to the bin\ directory in the PostgreSQL installation directory.
> .\wp_ctl.exe restart -w -D "c:\ProgramData\PostgreSQL\9.4\data\"
-wWait for the server to stop and start.-DPath to data directory. The version number may be different depending on the installation.
This appears to stop the PostgreSQL service & requires the service to be manually restarted.
- Start Menu > Services (command line:
services.msc) - Check the status of the postgresql service. (Its name will end with the version number.)
The PostgreSQL Windows port doesn't seem very reliable. I haven't found a reliable way to restart the server manually and to get the service running. So far the only reliable method is to reboot the Windows server.
Allowing remote access for pgAdmin III
- Make sure that the PostgreSQL port (default 5432) is open on the host machine.
- Edit
data\pg_hba.confin the PosgreSQL installation directory to give the remote machine access. (Requires the PostgreSQL server to be restarted.)[1] [2] - Confirm that that the PostgreSQL service is running in the Services control panel.
Notes
- ↑ The pg_hba.conf File PostgreSQL documentation
- ↑ IP range in pg_hba.conf? (PostgreSQL forums)
There is an explanation of CIDR masks at the end of the thread.