Normally, all production databases are deployed into private subnets within customer networks to limit the access to connections from within the network only. This is very good for security but does make it harder for developers or database administrators to connect to those databases.
Most people will use a publicly accessible VM, or Jump server, to connect to the database. We'll show you how this is done, but we'll also show how to connect if you do not have access to a VM using different OCI services.
For all the connections it is assumed that because the database is in a private subnet within the network, mTLS has been disabled and the network is configured to allow access to the necessary database ports.
Log into a jump server (aka VM) that is on the same private network as your Autonomous Database
Copy the connection string from Database connection screen (make sure you select TLS in the TLS authentication dropdown
sudo su - oracle
sql <user>/<password>@<connection string>
sqlplus <user>/<password>@<connection string>
Cloud Shell is a web browser-based terminal accessible from the Oracle Cloud Console. Cloud Shell is free to use and provides access to a Linux shell. What's nice is that it includes useful tools for connecting to and using OCI services, including the OCI APIs, CLI and SQL. Let's see how to connect to Autonomous Database using Cloud Shell.
You are now connected to your database!
Connections is an OCI service that allows you to connect to all your databases in a secure way without having the create and maintain bastion servers or other components. The instructions on how to do this can be found here.
Once you have created the connection, you can access the database from a SQL worksheet or SQLcl session within the Cloud Shell.
To access the database with the SQL worksheet:
To access the database using SQLcl:
You can now use the SQLcl session!
The information that you will need to create the connection:
ssh -i <privateKey> -N -L <localPort>:10.0.1.42:1521 -p 22 ocid1.bastionsession.oc1.eu-frankfurt-1.amaaaaaaei...@host.bastion.eu-frankfurt-1.oci.oraclecloud.com
Securing access to your data is so important - but it can add some complexity when trying to make a connection. Hopefully, these four options help you connect to your Autonomous Database! For more information, check out the Autonomous Database documentation.
Quentin is a solutions architect with twenty five years experience in the IT industry having worked in all areas from infrastructure and operations to design and development, within the finance, communications and technology sectors.