Postgres on Cygwin

Use the ubiquitous cygwin installer (setup.exe), select databases and then postgres, install it, and then..

$ /usr/sbin/postgres.exe --version
postgres (PostgreSQL) 8.2.11

$ export CYGWIN=server

$ /usr/sbin/cygserver &
[1] 5188
cygserver: Initialization complete.  Waiting for requests.

$ /etc/rc.d/init.d/postgresql initdb
The files belonging to this database system will be owned by user "senvaiya".
This user must also own the server process.
The database cluster will be initialized with locale C.
creating directory /usr/share/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 40
selecting default shared_buffers/max_fsm_pages ... 32MB/204800
creating configuration files ... ok
creating template1 database in /usr/share/postgresql/data/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.
Success. You can now start the database server using:
 /usr/sbin/postgres -D /usr/share/postgresql/data
or
 /usr/sbin/pg_ctl -D /usr/share/postgresql/data -l logfile start
done.

$ /usr/sbin/postgres.exe -D /usr/share/postgresql/data
LOG:  database system was shut down at 2009-06-26 20:40:04 PDT
LOG:  checkpoint record is at 0/485AD0
LOG:  redo record is at 0/485AD0; undo record is at 0/0; shutdown TRUE
LOG:  next transaction ID: 0/593; next OID: 10820
LOG:  next MultiXactId: 1; next MultiXactOffset: 0
LOG:  database system is ready
^C
LOG:  received fast shutdown request
LOG:  shutting down
LOG:  database system is shut down

$ /usr/sbin/pg_ctl -D /usr/share/postgresql/data -l logfile start
server starting

Here are some canned start/stop scripts :
$ cat pg-start 
:
set -x
export CYGWIN=server
export PGDATA=/usr/share/postgresql/data
/usr/sbin/cygserver &
sleep 5
/usr/sbin/pg_ctl -D "${PGDATA}" -l /var/log/postgresql.log  start

$ cat pg-stop 
:
set -x
export CYGWIN=server
export PGDATA=/usr/share/postgresql/data
/usr/sbin/pg_ctl stop
/usr/sbin/cygserver --shutdown

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s