Purpose
The CREATE USER statement is used to create a new OceanBase Database user. After a new user is created, you can use the new user to connect to OceanBase Database.
Privilege requirements
To execute the CREATE USER statement, the current user must have the CREATE USER system privilege. For more information about OceanBase Database privileges, see Privilege classification in Oracle-compatible mode.
Syntax
CREATE USER user_name
{ IDENTIFIED BY [VALUES] password
| IDENTIFIED WITH auth_plugin [BY password]
}
[REQUIRE {NONE | SSL | X509 | tls_option}]
[PROFILE profile_name]
[DEFAULT TABLESPACE {tablespace_name | NULL}];
tls_option:
CIPHER cipher_name
| ISSUER issuer_name
| SUBJECT subject_name
Parameters
Parameter |
Description |
|---|---|
| user_name | The username. After a new user is created, a new row is added to the dba_users table. If a user with the same name already exists, an error is returned. |
| IDENTIFIED BY | Specifies the password for the new user. The password is stored in plain text in the dba_users table. The server will store it as ciphertext. If the password contains special characters ~!@#%^&*_-+=`|(){}[]:;',.?/, you must enclose it in double quotation marks ("). |
| IDENTIFIED BY VALUES | Specifies the password for the new user. The password is stored in ciphertext in the dba_users table. |
| IDENTIFIED WITH | Specifies the authentication plugin and corresponding authentication information. The supported authentication plugin is caching_sha2_password (a password-based authentication plugin using SHA-256). BY password: Specifies a plaintext password.
NoteThe |
| REQUIRE | Specifies the password verification requirements for the user. Valid values:
|
| tls_option | Specifies the specific option for TLS requirements. Valid values:
|
| PROFILE | Specifies the user profile. A user profile is a predefined set of privileges and limitations that can be applied to the created user. |
| WITH auth_plugin | Optional. Specifies the user authentication plugin. Currently, authentication plugins such as mysql_native_password are supported. |
| DEFAULT TABLESPACE | Specifies the default tablespace for the user. A tablespace is a logical structure used to store user data. Specifying NULL means no default tablespace is set. |
Examples
Create a user named
test1with a plaintext password.obclient [SYS]> CREATE USER test1 IDENTIFIED BY "********";Create a user named
test2with an encrypted password and specify that SSL connections must be used for authentication.obclient [SYS]> CREATE USER test2 IDENTIFIED BY VALUES "********" REQUIRE SSL;Create the user
test3and explicitly specify to use thecaching_sha2_passwordauthentication plugin.obclient [SYS]> CREATE USER test3 IDENTIFIED WITH caching_sha2_password BY "********";
References
For information about how to grant privileges to a user, see Directly grant privileges.
You can view the information about the created user in the
dba_userstable. For more information about thedba_userstable, see DBA_USERS.For information about how to connect to OceanBase Database using the created user, see Connect to OceanBase Database.
