doctl Verified current stable Not installed? Security

Doctl / Create Database User With Username

Create Database User With Username

Create a new database user with a specific username.

$
Terminal
doctl d u c <database_id> <user_name>

When To Use

When onboarding new users to the database with tailored access rights.

Pro Tip

Avoid using easily guessable usernames to strengthen security posture.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
doctl d u c <database_id> <user_name>

Anatomy of Output

Understanding the result

User `example_user` created in database `my_database`. Operation Status

Indicates successful creation of user.

Default Privileges: Read, Write, Execute Permissions Overview

Initial permissions granted to the new user.

Creation Timestamp: 2023-10-10 12:55:00 UTC Time Log

When the user account was successfully created.

Power User Variants

Optimized versions

doctl databases user create -t access_token database_id example_user

Securely create a user utilizing an access token.

doctl databases user create database_id --name example_user

Alternative command structure for creating a user.

Troubleshooting

Common pitfalls

Error: Username already exists in database.

Solution: Choose a different username or delete the existing user prior to creation.

Error: Database ID does not exist.

Solution: Ensure that the provided database identifier is valid.

Error: Insufficient privileges to create users.

Solution: Verify user permissions prior to executing the command.

Command Breakdown

What each part is doing

doctl
Base Command
The executable that performs this operation. Here it runs Doctl before the shell applies any redirect operators.
d
d|databases
The value supplied for d|databases.
u
u|user
The user value supplied to this command.
c
c|create
The value supplied for c|create.
<database_id>
database id
The value supplied for database id.
<user_name>
user name
The user value supplied to this command.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.