PostgreSQL Cookbook: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| Line 14: | Line 14: | ||
* Run '''pgAdmin III'''. | * Run '''pgAdmin III'''. | ||
* Connect to the local server. | |||
* '''Tools''' > '''Server Configuration''' > '''pg_hba.conf''' or '''postgresql.conf''' > '''File''' > '''Reload Server''' | |||
=== Restarting manually === | === Restarting manually === | ||
| Line 41: | Line 42: | ||
* Edit `data\pg_hba.conf` in the PosgreSQL installation directory to give the remote machine access. (Requires the PostgreSQL server to be restarted.)<ref>[http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html The pg_hba.conf File] PostgreSQL documentation</ref> <ref>[http://postgresql.nabble.com/IP-range-in-pg-hba-conf-td4973998.html IP range in pg_hba.conf?] (PostgreSQL forums)<br />There is an explanation of CIDR masks at the end of the thread.</ref> | * Edit `data\pg_hba.conf` in the PosgreSQL installation directory to give the remote machine access. (Requires the PostgreSQL server to be restarted.)<ref>[http://www.postgresql.org/docs/9.3/static/auth-pg-hba-conf.html The pg_hba.conf File] PostgreSQL documentation</ref> <ref>[http://postgresql.nabble.com/IP-range-in-pg-hba-conf-td4973998.html IP range in pg_hba.conf?] (PostgreSQL forums)<br />There is an explanation of CIDR masks at the end of the thread.</ref> | ||
* Confirm that that the PostgreSQL service is running in the '''Services''' control panel. | * Confirm that that the PostgreSQL service is running in the '''Services''' control panel. | ||
* ipv6 address must be added to `pg_hba.conf` on Windows. Append `/128` to open the entire subnet of local addresses. | |||
== Notes == | == Notes == | ||
<references /> | <references /> | ||
Revision as of 00:35, 22 March 2015
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
- Run pgAdmin III.
- Connect to the local server.
- Tools > Server Configuration > pg_hba.conf or postgresql.conf > File > Reload Server
Restarting manually
I am including the information below because it's the most commonly documented method. It did not work reliably on Windows, however. It seems like not every process would be killed, and that some of them would still be attached to port 5432. The service could not be restarted after the server was stopped.
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.[1]
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.)
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.)[2] [3] - Confirm that that the PostgreSQL service is running in the Services control panel.
- ipv6 address must be added to
pg_hba.confon Windows. Append/128to open the entire subnet of local addresses.
Notes
- ↑ pg_ctl (PostgreSQL documentation)
- ↑ 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.