Purpose
You can use this statement to create an OceanBase Database user. After you create a user, you can use it to connect to OceanBase Database.
Note
To execute this statement, you must have the global CREATE USER privilege.
Syntax
CREATE USER [IF NOT EXISTS] user_specification_list
[REQUIRE {NONE | SSL | X509 | tls_option}];
user_specification_list:
user_specification [, user_specification ...]
user_specification:
user IDENTIFIED BY 'authstring'
| user IDENTIFIED BY PASSWORD 'hashstring'
tls_option:
| CIPHER 'cipher'
| ISSUER 'issuer'
| SUBJECT 'subject'
Parameters
| Parameter | Description | |
|---|---|---|
| IF NOT EXISTS | If the username already exists and IF NOT EXISTS is not specified, an error is returned. |
|
| user_name | The username. For each user created, a new entry is created in the mysql.user table. If the username already exists, an error is returned. |
|
| IDENTIFIED BY | You can use the optional IDENTIFIED BY clause to specify a password for the account. If the password contains special characters, |
it must be enclosed in double quotation marks. Special characters are ~ ! @ # % ^ & * _ - + = ` ( ) { } []: ; ' , . ? / |
| user_name [, user_name ...] | Multiple usernames must be separated with commas (,). | |
| REQUIRE | The encryption protocol for the user, Valid values: NONE, SSL, X509, and tls_option. |
|
| user IDENTIFIED BY 'authstring' | The password is in plaintext. After it is saved to the mysql.user table, the server stores it in ciphertext. |
|
| user IDENTIFIED BY PASSWORD 'authstring' | The password is in ciphertext. |
Examples
Create users
sqluser01andsqluser02, and set their passwords to******.obclient> CREATE USER 'sqluser01' IDENTIFIED BY '******', 'sqluser02' IDENTIFIED BY '******';Query the users that you created.
obclient> CREATE USER 'sqluser01' IDENTIFIED BY '******', 'sqluser02' IDENTIFIED BY '******'; Query OK, 0 rows affected obclient> SELECT user FROM mysql.user; +-----------+ | user | +-----------+ | root | | admin | | sqluser01 | | sqluser02 | +-----------+ 4 rows in set