$ brew install libpq
Psql is the interactive terminal for working with Postgres
$ psql -h localhost -U username databasename
* -h the host to connect to
* -U the user to connect with
* -p the port to connect to (default is 5432)
$ psql "dbname=dbhere host=hosthere user=userhere password=pwhere port=5432 sslmode=require"
rcherara=# \d
List of relations
Schema | Name | Type | Owner
--------+--------------------+----------+----------
public | customer | table | postgres
public | hibernate_sequence | sequence | postgres
(2 rows)
rcherara=# \d customer
Table "public.customer"
Column | Type | Collation | Nullable | Default
-----------+------------------------+-----------+----------+---------
id | bigint | | not null |
firstname | character varying(255) | | |
lastname | character varying(255) | | |
Indexes:
"customer_pkey" PRIMARY KEY, btree (id)
rcherara-# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
--------------+----------+----------+-------------+-------------+-----------------------
mydatabase | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
rcherara | rcherara | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
reservations | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(6 rows)
rcherara-#
rcherara-# \c reservations
You are now connected to database "reservations" as user "rcherara".