How to Retrieve Connection Details for Vultr Managed Databases for PostgreSQL
-
by Blog Admin
- 7
How to find and use the connection credentials needed to access your Vultr Managed PostgreSQL database
Managed database connection details consist of host, port, username, password, default database, connection strings, and SSL certificates. These credentials allow you to connect to the managed databases from your favorite database client or modern programming language libraries. These include the terminal-based front-end to PostgreSQL (psql
), PostgreSQL adapter for Python (Psycopg
), Go PostgreSQL driver (github.com/lib/pq
), and PostgreSQL Driver for PHP (pg_connect
).
Follow this guide to manage connection details for Vultr Managed Databases for PostgreSQL using the Vultr Customer Portal, API, CLI, or Terraform.
Vultr Customer Portal
- Navigate to Products and select Databases.
- Click the target database instance.
- Navigate to Connection Details under Overview.
- Click Copy Connection String.
- Click Copy PostgreSQL URL.
- Click Download Signed Certificate and save the certificate.
Vultr API
- List all the database instances by sending a
GET
request to the List Managed Databases endpoint and note the database ID. For example,43b4c774-5dff-4ac0-a01f-78a23c2205b5
.console$ curl "https://api.vultr.com/v2/databases" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}"
- Send a
GET
request to the Get Managed Database endpoint and specify a database ID.console$ curl "https://api.vultr.com/v2/databases/database_id" \ -X GET \ -H "Authorization: Bearer ${VULTR_API_KEY}"
Visit the Get Managed Database endpoint to view additional attributes to add to your request.
- Copy the
host
,port
,user
,password
, anddbname
values.
Vultr CLI
- List all database instances and note the database ID. For instance,
d6ac2a3c-92ea-43ef-8185-71a23e58ad8c
.console$ vultr-cli database list --summarize
- Retrieve connection details by specifying the database ID.
console
$ vultr-cli database get database_id
Run
vultr-cli database get --help
to view all options.
Terraform
- If you manage the database with Terraform, you can output connection details from the resource.
terraform
# Assuming a managed database resource exists resource "vultr_database" "pg" { database_engine = "pg" database_engine_version = "16" region = "ewr" plan = "vultr-dbaas-startup-cc-1-55-2" label = "pg-cluster-1" } output "pg_host" { value = vultr_database.pg.host } output "pg_port" { value = vultr_database.pg.port } output "pg_user" { value = vultr_database.pg.user } output "pg_dbname" { value = vultr_database.pg.dbname } # output "pg_password" { value = vultr_database.pg.password sensitive = true }
- Apply the configuration and view the outputs with
terraform output
.
How to find and use the connection credentials needed to access your Vultr Managed PostgreSQL database Managed database connection details consist of host, port, username, password, default database, connection strings, and SSL certificates. These credentials allow you to connect to the managed databases from your favorite database client or modern…
How to find and use the connection credentials needed to access your Vultr Managed PostgreSQL database Managed database connection details consist of host, port, username, password, default database, connection strings, and SSL certificates. These credentials allow you to connect to the managed databases from your favorite database client or modern…