Learn how to create, modify, and manage user accounts for your Vultr Managed Database for Valkey instance.
Database users are accounts that connect and query managed databases, usually by specifying a username and a password. These accounts provide access control and prevent unauthorized access to your database. After creating a database user, you can define their privileges on the database level to fine-tune the database security.
Follow this guide to manage database users for Vultr Managed Databases for Valkey using the Vultr Customer Portal, API, CLI, or Terraform.
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.
$ curl "https://api.vultr.com/v2/databases" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Send a POST request to the **Create Database User* endpoint specifying the database ID and the user credentials (username and password).
$ curl "https://api.vultr.com/v2/databases/database_id/users" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"username" : "john_doe",
"password" : "example_password"
}'
Visit the Create Database User endpoint to view additional attributes to add to your request.
List the user details by sending a GET request to the Get Database User endpoint and specify the database ID.
$ curl "https://api.vultr.com/v2/databases/database_id/users" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Send a DELETE request to the Delete Database User endpoint specifying the database ID and the username to delete a user.
$ curl "https://api.vultr.com/v2/databases/database_id/users/username" \
-X DELETE \
-H "Authorization: Bearer ${VULTR_API_KEY}"
List all database instances and note the database ID. For instance, d6ac2a3c-92ea-43ef-8185-71a23e58ad8c.
$ vultr-cli database list --summarize
Add a new user by specifying a database ID, username, and password.
$ vultr-cli database user create database_id \
--username john_doe \
--password example_password
List all database users by specifying a database ID.
$ vultr-cli database user list database_id
Delete a user from the database by specifying a database ID and a username.
$ vultr-cli database user delete database_id username
Run vultr-cli database user --help to view all options.
Ensure the Vultr Terraform provider is configured.
Create a database user with Terraform.
terraform {
required_providers {
vultr = {
source = "vultr/vultr"
version = "~> 2.26"
}
}
}
provider "vultr" {}
# Existing database assumed
variable "database_id" { type = string }
resource "vultr_database_user" "john" {
database_id = var.database_id
username = "john_doe"
password = "example_password"
}
To delete the user, remove the resource block or run:
$ terraform destroy -target vultr_database_user.john