How To Connect To Database On PostgreSQL

 

You can use pgadmin or psql to connect to the PostgreSQL database.

I do not prefer to do database administration with pgadmin.

You can simply connect to the database by downloading and installing pgadmin.

 

Connect With sqlplus

In this article we will examine the options to connect to the database with psql.

First of all, we should connect to the server with ssh and we pass to the postgres user with the following command.

You can also connect to the database using psql from a remote server.

We will see how to do this by making examples in later parts of the article.

 

If you run the following command, by default the postgres user will be connected to the postgres database.

 

If you did not change anything in the pg_hba.conf file after installing Postgres, it will not ask for a password.

For all configurations that can be done from the pg_hba.conf file, I recommend reading the article named “How To Configure pg_hba.conf File On PostgreSQL”.

This file is crucial for PostgreSQL.

 

Connection Options

If you want to connect to a specific database with a specific user, you should use the -d and -U parameters as follows.

 

If you want to connect to a specific database with a specific user, you should use the -d and -U parameters as follows.

dbtut
Author: dbtut

We are a team with over 10 years of database management and BI experience. Our Expertises: Oracle, SQL Server, PostgreSQL, MySQL, MongoDB, Elasticsearch, Kibana, Grafana.

Leave a Reply

Your email address will not be published. Required fields are marked *