Command
psql -h localhost -U username -d database
Examples
Connect to database
psql -h localhost -U postgres -d mydb
Connect with connection string
psql postgresql://user:pass@localhost:5432/mydb
psql -h localhost -U username -d database
Connect to database
psql -h localhost -U postgres -d mydb
Connect with connection string
psql postgresql://user:pass@localhost:5432/mydb