Skip to content

Instantly share code, notes, and snippets.

@bradkrane
Last active October 2, 2020 17:03
Show Gist options
  • Save bradkrane/4f4bc608e23506b297e6219f0bc0de5f to your computer and use it in GitHub Desktop.
Save bradkrane/4f4bc608e23506b297e6219f0bc0de5f to your computer and use it in GitHub Desktop.
Setup psql 12.0 on Windows 10 - No password localhost windows users

Setup psql 12.0 on Windows 10

  • No password localhost windows users
  • Usefull for on the command line: type <some_file>.psql | psql
  • Windows Binary 12.X as of writing https://www.postgresql.org/download/
  • Remember the postgress password for the step when opening pgAdmin later

Default install path: C:\Program Files\PostgreSQL\12\

Add pgsql path to command line Windows search 'Path' ahnd select: Environment Variables... For all users edit the System path variable for user only edit the User path variable New and add C:\Program Files\PostgreSQL\12\bin

To trust local users for no password on command line required replace C:\Program Files\PostgreSQL\12\data\pg_hba.conf with: https://gist.github.com/bradkrane/e5da73561b8f6c3dcce000d20bbd7eb8

host all all 127.0.0.1/32 trust host all all ::1/128 trust

Now on the command line you should get:

C:\Users\Brad Krane>psql psql: error: could not connect to server: FATAL: role "Brad Krane" does not exist https://stackoverflow.com/questions/17633422/psql-fatal-database-user-does-not-exist

Add your Windows username as a roll in the admin console roll Open pgAdmin and edit add the role. Login/Group Roles -> Create -> Login/Group Role Set the name as the FATAL role above: Brad Krane Privledges -> Can login? and Superuser? or whatever works

  • When setting up users/roles in pgAdmin they are case sensitive and should match your Windows username exactly.

Create DB for your role same name Databases -> Create -> Databases... Call Database the same as the role/user name

Now on the command line you should get:

C:\Users\Brad Krane>psql psql (12.4) WARNING: Console code page (437) differs from Windows code page (1252) 8-bit characters might not work correctly. See psql reference page "Notes for Windows users" for details. Type "help" for help.

Brad Krane=#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment