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 PostgreSQL using the Vultr Customer Portal, API, or CLI.
Navigate to Products and select Databases.
Click the target database instance.
Navigate to Users & Databases and click Add New User.
Enter the username, 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.
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"
}'
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}"
Visit the Delete Database User endpoint to view additional attributes to add to your request.
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 and database credentials (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.