grant Verified current stable Not installed? Security

Grant / Grant Role To User

Grant Role To User

Assigns a specified role to a user account.

$
Terminal
grant <role_name> to <username>;

When To Use

When onboarding a new user requiring specific permissions.

Pro Tip

Perform this in conjunction with auditing roles to ensure alignment with security policies.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
grant <role_name> to <username>;

Anatomy of Output

Understanding the result

GRANT my_role TO my_user; Command

Executes the role assignment.

GRANT succeeded. Output

Confirms role assignment was successful.

ERROR: user "my_user" does not exist Warning

Indicates the specified user was not found.

Power User Variants

Optimized versions

GRANT my_role TO my_user WITH ADMIN OPTION;

Grants the ability for 'my_user' to further assign the role.

Troubleshooting

Common pitfalls

ERROR: role my_role does not exist

Solution: Verify the spelling of the role name.

ERROR: user my_user is already a member of role my_role

Solution: Confirm the user's current role membership.

ERROR: insufficient privileges to grant role "my_role"

Solution: Ensure your current role has sufficient permissions.

Command Breakdown

What each part is doing

grant
Base Command
The executable that performs this operation. Here it runs Grant before the shell applies any redirect operators.
<role_name>
role name
The value supplied for role name.
<username>
username
The user value supplied to this command.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.