Connecting to a Database
OCI Database with PostgreSQL database system endpoints aren't directly accessible from the internet. Applications that need to connect to the database require connectivity to the VCN and private subnet of the database system.
Use one of the following methods to connect to a database in OCI Database with PostgreSQL for data management tasks:
- Using a Bastion Port Forwarding Session
- Using site-to-site VPN between your on-premises network and the VCN of the database system. For more information, see Site-to-Site VPN.
Using a Bastion Port Forwarding Session
If you're connecting to the database using a Bastion port forwarding session, you can connect directly from a local network to the database. You don't need to configure a Compute instance to connect from.
Use the following instructions to get started:
Bastion sessions aren't permanently available. SSH port forwarding sessions use only one IP address at a time, and require a new session for each private IP address. For more information, see Session Types.
Verifying Prerequisites
Verify that the required IAM resources and OCI network are in place. For more information, see Getting Started with OCI Database with PostgreSQL.
You can use Bastion to securely connect to a database for data management tasks. A bastion exists in the public subnet of the same VCN that contains the database system. Bastions establish the network infrastructure needed to connect a user to a target resource in the private subnet, such as a database system.
If there isn't a bastion in the VCN, create one and ensure that it has access to the private subnet of the database system. For more information, see Allowing Network Access From a Bastion.
When you create the session, specify port 5432
.
Installing the PostgreSQL Client
On a local machine, install a version of the PostgreSQL client that's compatible with the PostgreSQL version of the database system by following the instructions at https://www.postgresql.org/download/.
Connecting to the Database
Sign in to the database using the PostgreSQL client installed on a local machine.
You're now signed in to the PostgreSQL database.