Using the Command Line Interface (CLI)
Use the CLI to create Database Tools connections.
For information about using the CLI, see Command Line Interface (CLI). For a complete list of flags and options available for CLI commands, see the Command Line Reference.
Topics:
For Oracle Database Connections
- To create a connection to ADB with public IP using mTLS
- To create a connection to ADB with public IP using mTLS in JSON file
- To create a connection to an Oracle VM DB system using a private endpoint
- To create a proxy connection to Oracle Database with user name
- To create a proxy connection to Oracle Database with advanced properties
- To create a proxy connection to Oracle Database with the proxy-client parameter
- To create a proxy connection to Oracle Database with the proxy-client parameter in JSON file
To create a connection to ADB with public IP using mTLS
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-oracle-database -c <target_compartment_ocid> --user-name <database_user> --user-password-secret-id <vault_secret_ocid> --key-stores <keystore_json_array> --connection-string <connection_string> --display-name <connection_name>
This example assumes required secrets already exist in a vault.
For example, specifying all required details as arguments:
oci dbtools connection create-oracle-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --key-stores '[{ "keyStoreContent":{ "secretId": "ocid1.vaultsecret.oc1.phx.example1ssowalletxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya","valueType": "SECRETID" }, "keyStoreType": "SSO" }]' --connection-string '(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=example_databaseservice_low.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))' --display-name example-connection
To create a connection to ADB with public IP using mTLS in JSON file
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection as
specified in the JSON file:
oci dbtools connection create-oracle-database --from-json "file://<path-to-json>"
This example assumes required secrets already exist in a vault.
For example, specifying all required details in a JSON file:
{
"compartmentId": "ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz",
"connectionString": "(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-phoenix-1.oraclecloud.com))
(connect_data=(service_name=example_databaseservice_low.adb.oraclecloud.com))
(security=(ssl_server_cert_dn=\"CN=adwc.uscom-east-1.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US\")))",
"displayName": "example-connection-from-json",
"keyStores": [
{
"keyStoreContent": {
"secretId": "ocid1.vaultsecret.oc1.phx.example1ssowalletxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya",
"valueType": "SECRETID"
},
"keyStoreType": "SSO"
}
],
"userName": "example-user",
"userPasswordSecretId": "ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya"
}
In this example there is a JSON file in the current working directory called
example.json
as shown
above.
oci dbtools connection create-oracle-database --from-json "file://example.json"
To create a connection to an Oracle VM DB system using a private endpoint
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-oracle-database -c <target_compartment_ocid> --user-name <database_user> --user-password-secret-id <vault_secret_ocid> --connection-string <connection_string> -private-endpoint-id <private_endpoint_ocid> --display-name <connection_name>
This example assumes required secrets already exist in a vault.
For example:
oci dbtools connection create-oracle-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --connection-string "examplevmdb.privatesubnet.example.oraclevcn.com:1521/example_pdb.privatesubnet.example.oraclevcn.com" --private-endpoint-id ocid1.databasetoolsprivateendpoint.oc1.phx.exampleendpoint25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabcdefg --display-name example-connection
To create a proxy connection to Oracle Database with user name
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-oracle-database -c <target_compartment_ocid>
--user-name <database_user[proxy_client]> --user-password-secret-id <vault_secret_ocid>
--key-stores <keystore_json_array> --connection-string <connection_string>
--private-endpoint-id <private_endpoint_ocid> --display-name <connection_name>
This example assumes a private endpoint and the required secret in a vault already exist. This example can be used without proxy authentication.
For example:
oci dbtools connection create-oracle-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user[proxy-client]" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --connection-string "(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=example_databaseservice_low.adb.oraclecloud.com))(security=(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com,OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))" --key-stores '[{ "keyStoreContent":{ "secretId": "ocid1.vaultsecret.oc1.phx.example1ssowalletxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya", "valueType": "SECRETID" }, "keyStoreType": "SSO" }]' --private-endpoint-id ocid1.databasetoolsprivateendpoint.oc1.phx.exampleendpoint25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabcdefg --display-name example-connection
To create a proxy connection to Oracle Database with advanced properties
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-oracle-database -c <target_compartment_ocid>
--user-name <database_user> --user-password-secret-id <vault_secret_ocid> --key-stores <keystore_json_array>
--connection-string <connection_string> --private-endpoint-id <private_endpoint_ocid>
--display-name <connection_name> --advanced-properties <advanced_properties_json>
This example assumes a private endpoint and the required secret in a vault already exist. This example can be used without proxy authentication.
For example:
oci dbtools connection create-oracle-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --connection-string "(description= retry_count=20)(retry_delay=3)(address=(protocol=tcps) (port=1522)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=example_databaseservice_low.adb.oraclecloud.com)) (security=(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))" --key-stores '[{ "keyStoreContent":{ "secretId": "ocid1.vaultsecret.oc1.phx.example1ssowalletxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya", "valueType": "SECRETID" }, "keyStoreType": "SSO" }]' --private-endpoint-id ocid1.databasetoolsprivateendpoint.oc1.phx.exampleendpoint25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabcdefg --display-name example-connection --advanced-properties '{ "oracle.jdbc.proxyClientName": "proxy-client" }'
To create a proxy connection to Oracle Database with the proxy-client parameter
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-oracle-database -c <target_compartment_ocid> --user-name
<database_user> --user-password-secret-id <vault_secret_ocid> --key-stores <keystore_json_array>
--connection-string <connection_string> --private-endpoint-id <private_endpoint_ocid>
--display-name <connection_name> --proxy-client <proxy_client_json>
This example assumes a private endpoint and the required secret in a vault already exist. This example can be used without proxy authentication.
For example:
oci dbtools connection create-oracle-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --connection-string "(description=(retry_count=20)(retry_delay=3)(address=(protocol=tcps) (port=1522)(host=adb.us-phoenix-1.oraclecloud.com)) (connect_data=(service_name=example_databaseservice_low.adb.oraclecloud.com)) (security=(ssl_server_cert_dn="CN=adwc.uscom-east-1.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US")))" --key-stores '[{ "keyStoreContent":{ "secretId": "ocid1.vaultsecret.oc1.phx.example1ssowalletxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya", "valueType": "SECRETID" }, "keyStoreType": "SSO" }]' --private-endpoint-id ocid1.databasetoolsprivateendpoint.oc1.phx.exampleendpoint25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabcdefg --display-name example-connection --proxy-client '{ "proxy-authentication-type": "USER_NAME", "user-name": "proxy-client", "roles": [ "connect" ]}'
To create a proxy connection to Oracle Database with the proxy-client parameter in JSON file
Open a command prompt and run oci dbtools connection
create-oracle-database
to create a new Database Tools connection as specified in
the JSON file:
oci dbtools connection create-oracle-database --from-json "file://<path-to-json>"
This example assumes a private endpoint and the required secret in a vault already exist. This example can be used without proxy authentication.
For example, specifying all required details in a JSON file:
{
"compartmentId": "ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz",
"connectionString": "(description= (retry_count=20)(retry_delay=3)(address=(protocol=tcps)(port=1522)(host=adb.us-phoenix-1.oraclecloud.com))(connect_data=(service_name=example_databaseservice_low.adb.oraclecloud.com))(security=(ssl_server_cert_dn=\"CN=adwc.uscom-east-1.oraclecloud.com, OU=Oracle BMCS US, O=Oracle Corporation, L=Redwood City, ST=California, C=US\")))",
"displayName": "example-connection-from-json",
"keyStores": [
{
"keyStoreContent": {
"secretId": "ocid1.vaultsecret.oc1.phx.example1ssowalletxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya",
"valueType": "SECRETID"
},
"keyStoreType": "SSO"
}
],
"userName": "example-user",
"userPasswordSecretId": "ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya",
"proxy-client": {
"proxy-authentication-type": "USER_NAME",
"user-name": "proxy-client",
"user-password": {
"value-type": "SECRETID",
"secret-id": "ocid1.vaultsecret.oc1.phx.amaaaaaacsc5xjaanv6tjndg4dujfcarguywkftbvgsolw5w6fb22rhpb6ta"
},
"roles": [ "connect" ]
}
}
For MySQL Database Connections
To create a connection to a MySQL Database
Open a command prompt and run oci dbtools connection
create-mysql-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-mysql-database -c <target_compartment_ocid> --user-name <database_user> --user-password-secret-id <vault_secret_ocid> --connection-string <connection_string> --display-name <connection_name>
This example assumes the required secret in a vault already exists.
For example:
oci dbtools connection create-mysql-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --connection-string "mysql://public-ip-or-fqdn:3306/exampledatabase" --display-name example-connection
To create a connection to a MySQL DB system
Open a command prompt and run oci dbtools connection
create-mysql-database
to create a new Database Tools connection within
the specified compartment:
oci dbtools connection create-mysql-database -c <target_compartment_ocid> --user-name <database_user> --user-password-secret-id <vault_secret_ocid> --connection-string <connection_string> --private-endpoint-id <private_endpoint_ocid> --display-name <connection_name>
This example assumes a private endpoint and the required secret in a vault already exist.
For example:
oci dbtools connection create-mysql-database -c ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz --user-name "example-user" --user-password-secret-id ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsabcdefzf3423ya --connection-string "mysql://10.0.0.42:3306/exampledatabase" --private-endpoint-id cid1.databasetoolsprivateendpoint.oc1.phx.exampleendpoint25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabcdefg --display-name example-connection
To create a connection to a MySQL DB system via JSON
Open a command prompt and run oci dbtools connection
create-mysql-database
to create a new Database Tools connection as
specified in the JSON file:
oci dbtools connection create-mysql-database --from-json "file://<path-to-json>"
This example assumes a private endpoint and the required secret in a vault already exist.
For example, specifying all required details in a JSON file:
{
"compartmentId": "ocid1.compartment.oc1..example1example25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabwk3zz",
"userName": "example-user",
"userPasswordSecretId": "ocid1.vaultsecret.oc1.phx.example1secrettxiu7mwuabcdefxl67fj5niy4akfzsababcdefzf3423ya",
"connectionString": "mysql://10.0.0.42:3306/exampledatabase",
"privateEndpointId": "cid1.databasetoolsprivateendpoint.oc1.phx.exampleendpoint25qrlpo4agcmothkbgqgmuz2zzum45ibplooqtabcdefg",
"displayName": "example-connection-from-json"
}
In this example, there is a JSON file in the current working directory called
example.json
as shown above.
oci dbtools connection create-mysql-database --from-json "file://example.json"