9

Is there any way to install PostgreSQL on windows using command prompt?
(Without using PostgreSQL installer)

Gaurav Chaudhary
  • 483
  • 1
  • 6
  • 12

2 Answers2

26
postgresql-9.3.3-1-windows-x64.exe --unattendedmodeui minimal --mode unattended --superpassword "password" --servicename "postgreSQL"
--servicepassword "password" --serverport 5432

Worth mentioning postgresql-9.3.3-1-windows-x64.exe --help will provide list of options and defaults which can be used.

abhishek77in
  • 1,848
  • 21
  • 41
Gaurav Chaudhary
  • 483
  • 1
  • 6
  • 12
15

Run the installer in unattended(silent) mode

-or-

download the plain binaries, initdb a new datadir, then start the server with pg_ctl. You can install a service with standard Windows tools like sc or can use pg_ctl register to create the service.

If you plan to bundle PostgreSQL in an application, please use the latter method (binary zip), and make sure you run it on a port other than the default port 5432 so your app doesn't conflict with any install the user might do themselves.

oers
  • 18,436
  • 13
  • 66
  • 75
Craig Ringer
  • 307,061
  • 76
  • 688
  • 778
  • I exclusively use the ZIP distribution. Installing Postgres that way seems to be much faster (and easier - at least to me) compared to the installer –  Mar 05 '14 at 10:29
  • Yeah. I tend to use a mixture of the PGDG packages for Fedora, and source builds. The main benefit of using the Windows installer (on Windows) is that it'll get psqlODBC etc for you, but that's not overly hard to do manually. – Craig Ringer Mar 05 '14 at 11:18
  • 4
    One thing you might want to add: you can create the Windows service using `pg_ctl register ...`, you don't need `sc` for that. –  Mar 05 '14 at 11:37
  • @a_horse_with_no_name: I am trying to use the same command. Its working . but the visual studio installer GUI is popping up and i am not able to see the pgadmin. But i can see that postgresql got installed in program files and the service is also there. Can you please help me out. I do not wish to have a gui to come up since i will be using with powershell(Invoke-command) – Ranadip Dutta Apr 25 '17 at 05:00
  • See [@a_horse_with_no_name answer](https://stackoverflow.com/a/14485121/1098603) for the syntax of `pg_ctl register ...`. – Matthieu Oct 08 '19 at 16:38