37

How can I start PostgreSQL and pgAdmin III in windows without installation. I do not have admin rights in a system. so I need to start the application without installing . How can I do that?

user3263117
  • 407
  • 1
  • 7
  • 12
  • may be this can help you https://www.tutlinks.com/install-postgresql-without-admin-rights-windows/ – navule May 19 '20 at 17:20

3 Answers3

84
  1. Download the ZIP file from https://www.enterprisedb.com/download-postgresql-binaries

  2. Unzip the archive into a directory of your choice (the archive is created such that unzipping it, it will create a directory pgsql with everything else below that)

  3. Run initdb (this can be found in the subdirectory pgsql\bin)

     initdb -D c:\Users\Arthur\pgdata -U postgres -W -E UTF8 -A scram-sha-256
    

    This will create the postgres "data directory" (aka the "cluster") in c:\Users\Arthur\pgdata. You need to make sure that the user running this command has full read/write privileges on that directory.

    -U postgres creates the superuser as postgres, -W will prompt you for the password of the superuser, -E UTF8 will create the database with UTF-8 encoding and -A scram-sha-256 enables the password authentication.

  4. To start Postgres, run:

     pg_ctl -D c:\Users\Arthur\pgdata -l logfile start
    

    this has(!) to be done as the user who ran initdb to avoid any problems with the access to the data directory.

  5. To shutdown Postgres, run:

     pg_ctl -D c:\Users\Arthur\pgdata stop
    
  6. psql.exe (the command line client) is located in the bin directory. Starting with Postgres 9.6 the pgAdmin executable pgAdmin4.exe is located in the sub-directory "pgAdmin 4\bin".

  7. Optionally create a Windows service to automatically run Postgres (must be run using a Windows administrator account)

     pg_ctl register -N postgresql -D c:\Users\Arthur\pgdata 
    
  • I tried the following steps but I am getting an error:$ ./postgres/bin/psql psql: FATAL: role "user" does not exist – dv3 Mar 22 '18 at 20:26
  • 1
    For those who are using `postgresql-10.4-1-windows`, pgAdmin4 will failed to connect to application server. `postgresql-9.6.9-1-windows` does not have this problem. – VCD Jun 01 '18 at 13:20
  • @SolomonUcko: four years ago there was no better way –  Nov 17 '18 at 20:32
  • Is there any way to see what other ones are available? – Solomon Ucko Nov 17 '18 at 20:58
  • 1
    @SolomonUcko: see the manual: https://www.postgresql.org/docs/current/client-authentication.html –  Nov 17 '18 at 22:20
  • creating directory c:/Users/Arthur/pgdata ... initdb: error: could not create directory "c:/Users/Arthur": Permission denied – Hasan A Yousef Oct 21 '19 at 14:48
  • Thanks a lot for this post, spent hours to install postgressql in windows trying each and every solution, finally able to do it with above steps and connect. So much frustrating. – Derrick Nov 05 '19 at 05:59
  • How can I set the path for pg_config for this case? – Shubham Srivastava Oct 08 '20 at 09:50
  • @a_horse_with_no_name can you please check this, I have followed the steps and have tried all the solutions , but no luck. Then created this , https://stackoverflow.com/questions/67046283/postgresql-initdb-initialize-a-new-database-cluster-has-stopped-working – Dragon Apr 11 '21 at 15:41
  • Is there an up-to-date link for the download? – erik-stengel Apr 04 '22 at 06:41
2

Thank you. This worked for me. But, i was getting error while starting psql.exe

The error was "psql: FATAL : role [user] does not exist."

To resolve this, i followed the below steps:

  1. Be on the same folder path (where you have initdb.exe) i.e. source-folder/pgsql/bin
  2. Run "psql -U postgres". This will ask for password.
  3. Now enter the password that was set during postgres intialization. This will open the psql command prompt.

Hope this helps.. :)

2

I tried above method its working fine, but when i tried to connect it via JDBC i used to get

"The authentication type 10 is not supported. Check that you have configured the pg_hba.conf file to include the client's IP address or subnet, and that it is using an authentication scheme supported by the driver."

This happens because scram-sha-256 has some issue(refer here), i couldn't understand in depth, so i changed it to md5, All started to work smoothly.hope it helps

.\initdb -D D:\database\dbdata -U postgres -W -E UTF8 -A md5

Vikram S
  • 551
  • 5
  • 5