Introduction :

PostgreSQL, commonly known as Postgres, is a powerful open-source relational database management system. It excels in data integrity, extensibility, and compliance with SQL standards. Postgres is widely utilized for handling complex and high-performance database applications. Its active community and continuous development.

Prerequisites:

PostgreSQL Installed: Ensure PostgreSQL is installed on your system. You can download it from the official PostgreSQL website.

Access Credentials: You need the following details to connect:

  • Host: The server address where your PostgreSQL instance is hosted (e.g., localhost or an IP address).
  • Port: The port on which your PostgreSQL server is listening (default is 5432).
  • Database Name: The name of the database you want to connect to.
  • Username: Your PostgreSQL username.
  • Password: Your PostgreSQL password.

Connect using Terminal

Connect Using psql: Use the following command to connect to your PostgreSQL server:

$ psql -h <host> -p <port> -d <database_name> -U <username>

Replace <host>, <port>, <database_name>, and <username> with your actual PostgreSQL connection details.

Enter Password: After running the above command, you will be prompted to enter your password. Enter your PostgreSQL password and press Enter.

If the connection is successful, you should see the PostgreSQL prompt

Connect using UI

The first time you open pgAdmin, you need to set up the server so the app knows where to connect.
Click Add New Server.
The create server screen will open.

When you’ve finished, click the Connection tab at the top.

Use the fields in the Connection tab to configure a connection:

  • Enter the IP address or server hostname you wish to connect to. For example, this could be the IP address 1.2.3.4 or a server hostname, like server.serverhostgroup.com.
  • Enter the listener port number of the server host in the Port field. The default is 5432.
  • The maintenance DB field is used to specify the initial database that pgAdmin connects to DB (optional).
  • Use the Username field to specify the username assigned to the database you’re connecting to.
  • Use the Password field to provide a password that goes with your database user account.
  • Check the box next to Save password? to instruct pgAdmin to save the password for future use if you want.

When you’ve finished, click Save. The pgAdmin app will attempt to connect to the server automatically, and the settings will be changed so the next time you open pgAdmin, you’ll be able to connect easily.

Leave a Reply