
\l Command is used to list all databases present in the PostgreSQL Database Cluster. Let us see the example of the PostgreSQL psql command in the following section. The format of the psqlĬommand is starting from a backslash that is followed by the command and then the argument. Once the connection is successful the prompt name is provided with the DB name. We can connect to PostgreSQL Database Cluster using the psql utility as mentioned above. $psql -U user -h host "dbname=db sslmode=require" PostgreSQL Psql Commands We can make a connection with PostgreSQL Database Cluster using the SSL mode. $psql -h host -d database -U user –W (Here -h =Hostname, -d =Database, -U = User, -W = Password) 3. We can connect to a specific hostname using the username and the password.
#Postgresql commands with examples password
Connect to Hostname Using Username and Password $psql -d database -U user –W (Here -d =Database, -U = User, -W = Password) sudo -i -u psql -d postgres -U postgres –W Output: 2. In the following example, we are using the postgres as the user name and the same for the DB name to make We can connect to a specific database name using the username and the password. Connect to Exact Database Using Username and Password

In this section, we will see those options.


There are multiple ways through which we can use the PostgreSQL psql command-line interface to connect to the PostgreSQL database cluster. psql provides the features such as writing the scripts and creating automation for various tasks. Pass an input file to psql or run the psql command on an interactive command-line interface. PostgreSQL psql is the command-line interactive tool that comes with the PostgreSQL installation package to interact with the PostgreSQL database cluster and run the SQL queries.
