How to Manage Users for Vultr Managed Databases for PostgreSQL

Updated on November 27, 2024

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.

  • Vultr Customer Portal
  • Vultr API
  • Vultr CLI
  1. Navigate to Products and select Databases.

  2. Click the target database instance.

    Select Managed Database

  3. Navigate to Users & Databases and click Add New User.

    Add new user

  4. Enter the username, define a strong password, and click Create New User.

    Enter the User Credentials

  5. Click Delete User to remove the user from the database or click Reset Password to change the user's password.

    Review Database Users

  1. 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}"
    
  2. Send a POST request to the Create Database User endpoint specifying the database ID and the user credentials (username and password).

    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"        
        }'
    
  3. 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}"
    
  4. Send a DELETE request to the Delete Database User endpoint specifying the database ID and the username to delete a user.

    console
    $ 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.

  1. List all database instances and note the database ID. For instance, d6ac2a3c-92ea-43ef-8185-71a23e58ad8c.

    console
    $ vultr-cli database list --summarize
    
  2. Add a new user by specifying a database ID and database credentials (username and password).

    console
    $ vultr-cli database user create database_id \
    --username john_doe \
    --password example_password
    
  3. List all database users by specifying a database ID.

    console
    $ vultr-cli database user list database_id
    
  4. 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.