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 USERprivilege.
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. |
| user_name [, user_name ...] | Multiple usernames must be separated with commas (,). |
| REQUIRE | Specifies an 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 to123456.obclient> CREATE USER 'sqluser01' IDENTIFIED BY '123456', 'sqluser02' IDENTIFIED BY '123456';Query the users that you created.
obclient> CREATE USER 'sqluser01' IDENTIFIED BY '123456', 'sqluser02' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.12 sec) obclient> SELECT user FROM mysql.user; +-----------+ user +-----------+ root admin sqluser01 sqluser02 +-----------+ 4 rows in set (0.00 sec)