Running pgcli without least privilege is a security hole waiting to be exploited. Databases hold critical data. Every connection is a potential attack path. Least privilege means giving each user, script, or tool exactly the permissions required, and nothing more.
pgcli, the popular command-line client for Postgres, supports connecting with specific database roles. But most teams still use superuser accounts for routine work. This creates risk. If your pgcli session is compromised, the attacker inherits every permission you have.
To apply least privilege in pgcli, create a dedicated database role with only the needed rights:
SELECTon specific tables for read-only tasksINSERTandUPDATEonly for target tables in data entry workflows- No
DROP,ALTER, orTRUNCATEwithout explicit operational need
Then connect with: