Logging in psql via command prompt

Psql is the interactive terminal for working with Postgres. Theres an abundance of flags available for use when working with psql, but lets focus on some of the most important ones, then how to connect:

  • -h the host to connect to
  • -U the user to connect with
  • -P the port to connect to (default is 5432)

Example

first you have to enter following first line

E:\postgre\bin>psql -U postgres
Password for user postgres:
psql (8.4.22)
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.

postgres=#

Line 1 is we have to type on our command prompt window, then it will ask for password and when authentication details are matched then your command prompt window will be ready as shown above.

Share

You may also like...