The password failed again.
You typed it. You checked it. Still, access denied. Pgcli is fast, friendly, and powerful, but without the right authentication setup, it’s a locked door. Getting authentication right is not just a matter of saving keystrokes — it’s about speed, security, and sanity.
Pgcli connects to Postgres with style: auto-completion, syntax highlighting, and a smooth command-line interface that makes database work sharper. But to connect, you need authentication that works every time, without friction. That means understanding how Pgcli handles credentials, which methods Postgres supports, and how to make them fit together.
Start with .pgpass. Stored in your home directory, it lets Pgcli log in without prompting for a password each time. Format matters: host, port, database, user, password. Set correct permissions — chmod 600 ~/.pgpass — or Postgres will ignore it. This is the simplest way to keep Pgcli quick.
For more control, lean on environment variables. PGHOST, PGPORT, PGDATABASE, PGUSER, and PGPASSWORD can be exported in your shell to make Pgcli connections effortless. Combine them with different profiles in your shell configuration to handle multiple databases.