1.18.2018

How to connect to a Postgres instance from Command Line / Terminal?

The following steps will explain on how to connect to your Postgres instance from command line or terminal if you are using Mac.

1. Make sure you have Postgres installed
2. From command line run the following command

psql -h localhost -p5432 -U superuser postgres

options:
-h host
-p port (default 5432)
-U username (default your machine login)
database (default postgres)

3. Enter the password when prompted for. This is either the one you created during Postgres installation or your machine login password
4. Now Type "helpfor help or \h for help with SQL commands or \? for help with psql commands

No comments:

Post a Comment