Connect to a Database
To manage data or database objects within your Relyt database using a third-party client tool (other than the Relyt console), you need to connect to the database first.
This section demonstrates how to connect to a Relyt database using psql
as an example.
Relyt is compatible with the PostgreSQL protocol, allowing you to use any PostgreSQL-compatible tool or software to connect to the Relyt database. For detailed instructions on other connection methods, please refer to the relevant sections in Connect to Relyt.
Prerequisites
-
At least one DW service unit for vectors exists in the environment.
-
At least one database exists in the target DW service unit for vectors.
-
You have obtained the username and password for an account, and the account has
CONNECT
privilege for the target database.
1. Install psql
This section explains how to install the psql
tool on Windows, Linux, and MacOS systems. Please choose the appropriate installation method based on your environment.
If psql
is already installed in your environment, skip this step.
- Windows
- Linux
- MacOS
-
Download the appropriate version of the installer from the PostgreSQL official website.
-
Double-click the downloaded installer and follow the instructions to complete the installation.
infoEnsure that the psql tool is selected during installation.
-
After installation, right-click the Computer or My Computer desktop icon and select Properties. Then, choose Advanced system settings > Advanced > Environment Variables.
-
In the System variables section, find
Path
and add the PostgreSQLbin
directory path (e.g.,C:\Program Files\PostgreSQL\13\bin
). -
Open the Command Prompt (
cmd
) and enterpsql --version
. If the version information is displayed, psql is installed.
-
Use a package manager to install:
a. For Debian/Ubuntu systems:
sudo apt update
sudo apt install postgresql postgresql-contribb. For CentOS/RHEL systems:
sudo yum install postgresql-server postgresql-contrib
-
Run
psql --version
. If the version information is displayed, psql is installed.
This section describes how to install psql
using Homebrew. You can choose any other installation method that suits your needs.
-
Install Homebrew.
noteIf Homebrew is already installed on your system, skip this step.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Use Homebrew to install PostgreSQL.
brew update
brew install postgresql -
Run
psql --version
. If the version information is displayed, psql is installed.
2. Connect to your Relyt database
Run the following command to connect to the Relyt database:
psql -h <endpoint_domain> -p <endpoint_port> -U <dw_user_name> -d <db_name>
Parameter description:
Parameter | Description |
---|---|
endpoint_domain | The public endpoint of the DW service unit. |
endpoint_port | The port number of the DW service unit, default is 5432. |
dw_user_name | The username for logging in to the DW service unit. |
db_name | The name of the Relyt database to connect. |
For more detailed parameter description and psql
usage instructions, see the relevant topic in the Connect to Relyt topic.