PostgreSQL Cookbook: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 11: Line 11:
* Create the database<br />'''Object browser''' > '''Server Groups''' > ''[server]'' > '''Databases''' > ''(right click)'' > '''New Database'''
* Create the database<br />'''Object browser''' > '''Server Groups''' > ''[server]'' > '''Databases''' > ''(right click)'' > '''New Database'''


== Restarting the service ==
== Restarting the server ==


The PostgreSQL service name includes the version number.  
The PostgreSQL service name includes the version number.  


With powershell run with Administrator privileges, find the name of the service:
With powershell run with Administrator privileges, navigate to the `bin\` directory in the PostgreSQL installation directory.


<syntaxhighlight lang="powershell">
<syntaxhighlight lang="powershell">
> get-service
> .\wp_ctl.exe restart -w -D "c:\ProgramData\PostgreSQL\9.4\data\"
</syntaxhighlight>
</syntaxhighlight>


Find the postgresql instance. Then stop and start the service:
* `-w` Wait for the server to stop and start.
* `-D` Path to data directory. The version number may be different depending on the installation.


<syntaxhighlight lang="powershell">
== Allowing remote access for pgAdmin III ==
> net stop postgresql-9.4
 
> net start postgresql-9.4
* Make sure that the PostgreSQL port (default 5432) is open on the host machine.
</syntaxhighlight>
* Edit `data\pg_hba.conf` in the PosgreSQL installation directory to give the remote machine access. (Requires the PostgreSQL server to be restarted.)
* Confirm that that the PostgreSQL service is running.
** '''Start Menu''' > '''Services'''
** Check the status of the postgresql service. (Its name will end with the version number.)

Revision as of 06:04, 21 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

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\"
  • -w Wait for the server to stop and start.
  • -D Path to data directory. The version number may be different depending on the installation.

Allowing remote access for pgAdmin III

  • Make sure that the PostgreSQL port (default 5432) is open on the host machine.
  • Edit data\pg_hba.conf in the PosgreSQL installation directory to give the remote machine access. (Requires the PostgreSQL server to be restarted.)
  • Confirm that that the PostgreSQL service is running.
    • Start Menu > Services
    • Check the status of the postgresql service. (Its name will end with the version number.)