DBA Hub

📋Steps in this guide1/1

How to connect to postgres db

How to connect to postgres db:

postgresql configurationintermediate
by PostgreSQL
14 views
1

How to connect to postgres db

set PATH if not done: connect to db using SYNTAX - psql -d -U Find current connection info: Switch to another database:

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
How to connect to postgres db:
postgres$
export PATH=/Library/PostgreSQL/10/bin:$PATH
postgres$
which psql
/Library/PostgreSQL/10/bin/psql
postgres$
psql -d edb -U postgres
Password for user postgres:
psql (10.13)
Type "help" for help.
postgres=#
postgres=#
\conninfo
You are connected to database "edb" as user "postgres" via socket in "/tmp" at port "5432".
postgres=#
select current_schema,current_user,session_user,current_database();
current_schema  | current_user | session_user | current_database
----------------+--------------+--------------+------------------
public         | postgres.     | postgres     | edb
postgres-#
\c dbaclass
You are now connected to database "dbaclass" as user "postgres".

Comments (0)

Please to add comments

No comments yet. Be the first to comment!