Verifying the Connection to the PostgreSQL Database Server

Before you create a PostgreSQL instance, you must verify the connection to the PostgreSQL database server.

Procedure

  1. Log on with a user account that has permissions to run the psql binary.

  2. Go to the bin folder in the PostgreSQL installation directory.

  3. Establish the postgresql connection:

    • On a Unix computer, run the following command:

      ./psql -p port -U <database_user> -d <database_name> -h <hostname>
    • On a Windows computer, run the following command:

      psql.exe -p port -U <database_user> -d <database_name> -h <hostname>

      Where:

      • database_user is a user that has permissions to perform backups and restores

      • database_name is the database that is available in the database server

      • hostname is the IP address or the fully qualified domain name of the computer that contains the database server

Example

The following example verifies the connection to the demopgsql database:

[root@mpgstandby bin]# cd /usr/pgsql-13/bin
[root@mpgstandby bin]# ./psql -p 5432 -U postgres -d demopgsql -h mpgstandby
psql (13.0)
Type "help" for help.
demopgsql=# \q
[root@mpgstandby bin]#

Loading...