Connection options:
-h, --host=HOSTNAME
# database server host or socket directory
# (default: "local socket")
-p, --port=PORT
# database server port
# (default: "5432")
-U, --username=USERNAME
# database user name (default: "root")
-w, --no-password
# never prompt for password
-W, --password
# force password prompt (should happen automatically)
Here port : 5432 is default and can be get from psql --help
postgres is the super user. Create another user and connect using that.
to connect to database with user :
\c db_name user_name
Commands
-- to list all tables
\dt
-- to list all databases
\l
-- to list all table spaces
\db
-- to list all schemas
\dn
-- to list all indices
\di
-- to list all sequences
\ds
-- to list all roles
\dg
-- to list data types
\dT
-- to list all domain datatypes
\dD
-- to list all views
\dv
-- to list previous commands
\g
-- to list Command History
\s
-- to run command from file
\i filename
-- it should be inside the server
-- to list help
\h
\h create table
-- to display null
\pset null (null)
-- to make terminal better
\pset linestyle unicode
\pset border 2
-- to watch a command in time
\watch 2
-- to turn on timing
\timing