556 B
556 B
Connect to Postgres Database Using Psql
- OPTION: connect to Postgres as admin user
sudo -u postgres psql -U postgres -W
- OPTION: connect to the database as user
psql -U <user name> -d <database name> -W
- OPTION: connect to the database as user to a remote Postgres instance at host and port (NOTE: Configure Postgres for remote connections like this)
psql -h <host name> -p <port number> -U <user name> -d <database name> -W