CREATE USER
- Capella Operational
- reference
- Couchbase Server 8.0
The CREATE USER statement enables you to create a user.
Purpose
Creating a user is an essential step in managing access to your Couchbase environment. You can use the CREATE USER statement to define a new local user in the Couchbase Server Role-Based Access Control (RBAC) system. By default, Couchbase Server assigns the user to the local authentication domain.
When you create a user, you can specify their basic attributes such as username, password, full name, and assign them to one or more groups. If you do not specify a group, the user is not assigned to any group by default.
RBAC Privileges
To execute the CREATE USER statement, you must be an Organization Owner or Project Owner.
Syntax
create-user ::= 'CREATE' 'USER' ( 'IF' 'NOT' 'EXISTS' )? username 'PASSWORD' password
( 'WITH' name )?
( 'GROUP' group | 'GROUPS' group ( ',' group )* | 'NO' 'GROUPS' )?
| username |
(Required) The unique identifier for the new local user. |
| password |
(Required) A quoted string containing the user’s password. It must be at least 6 characters long. |
| name |
(Optional) A quoted string containing the user’s full name. |
| group |
(Optional) The group you want to assign the user to. |
|
When creating a user, you can assign them to groups using one of the following options:
|
IF NOT EXISTS Clause
The optional IF NOT EXISTS clause enables the statement to complete successfully when the specified user already exists.
If a user with the same username already exists, then:
-
If this clause is not present, an error is generated.
-
If this clause is present, the statement does nothing and completes without error.
Examples
CREATE USER Hilary PASSWORD "password123" WITH "Hilary Smith";
CREATE USER Alice PASSWORD "password123" GROUP agents;
CREATE USER Bob PASSWORD "P@ssw0rd" GROUPS agents, tourguides, support;
CREATE USER Charlie PASSWORD "securePass" NO GROUPS;
CREATE USER IF NOT EXISTS David PASSWORD "davidPass" WITH "David Trantow";
Related Links
-
To update an existing user, see ALTER USER.
-
To delete a user, see DROP USER.
-
To create a new group, see CREATE GROUP.
-
To grant roles and privileges to a user, see GRANT.