Postgresql Related Notes

  • If you’ve installed postgresql using the installer, it typically sets the service to start automatically when Windows is started.  To check if postgresql is already running, issue net start in a command window and look for postgresql.
  • To start postgresql server:  pg_ctl.exe restart -D “<data file directory>”.  Note, using restart effectively issues pg_ctl.exe stop before restarting the process.
  • To start postgresql as a windows service:
    • first run services.msc to findout postgresql’s service name on your machine
    • issue net start <service name> from command line or click on it in the services.msc window.
  • To start at a different port:
    • pg_ctl “-p 5433” restart
  • To check status
    • pg_ctl status -D “<data directory>”
  • To check if a port is in use:
    • netstat -a -o (-o gives you the pid of the process that is using the port).
    • tasklist /fi “pid eq <pid #>” will list the process that’s using the port
  • To dump schema information into a file:
    • pg_dump -U <username> -d <dateabase name> -s -f <file name>