How to Manage Users for Vultr Managed Databases for MySQL
-
by Blog Admin
- 9
How to Manage Users for Vultr Managed Databases for MySQL
A guide explaining how to create, modify, and manage user accounts for Vultr Managed MySQL databases.
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 MySQL 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 Users & Databases and click Add New User.
- Enter the username, select password encryption, define a strong password, and click Create New User.
- Click Delete User to remove the user from the database or click Reset Password to change the user’s password.
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
POST
request to the Create Database User endpoint specifying the database ID and the user credentials (username
,password
, andencryption
).console$ 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", "encryption" : "caching_sha2_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.console$ 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 theusername
to delete a user.console$ curl "https://api.vultr.com/v2/databases/database_id/users/username" \ -X DELETE \ -H "Authorization: Bearer ${VULTR_API_KEY}"
Vultr CLI
- List all database instances and note the database ID. For instance,
d6ac2a3c-92ea-43ef-8185-71a23e58ad8c
.console$ vultr-cli database list --summarize
- Add a new user by specifying a database ID,
username
,password
andencryption
method.console$ vultr-cli database user create database_id \ --username john_doe \ --password example_password \ --encryption caching_sha2_password
- List all database users by specifying a database ID.
console
$ vultr-cli database user list database_id
- Delete a user from the database by specifying a database ID and a
username
.console$ vultr-cli database user delete database_id username
Run
vultr-cli database user --help
to view all options.
Terraform
- Ensure the Vultr Terraform provider is configured.
- Create a database user with Terraform.
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" encryption = "caching_sha2_password" }
- To delete the user, remove the resource block or run:
console
$ terraform destroy -target vultr_database_user.john
How to Manage Users for Vultr Managed Databases for MySQL A guide explaining how to create, modify, and manage user accounts for Vultr Managed MySQL databases. Database users are accounts that connect and query managed databases, usually by specifying a username and a password. These accounts provide access control and…
How to Manage Users for Vultr Managed Databases for MySQL A guide explaining how to create, modify, and manage user accounts for Vultr Managed MySQL databases. Database users are accounts that connect and query managed databases, usually by specifying a username and a password. These accounts provide access control and…