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. It is the password stored in the mysql.user table in ciphertext. |
Examples
Create users named
sqluser01andsqluser02, and specify passwords in plaintext.obclient> CREATE USER 'sqluser01' IDENTIFIED BY '******', 'sqluser02' IDENTIFIED BY '******';Create a user named
sqluser03and specify a password in ciphertext.// Query the password in ciphertext. obclient> SELECT PASSWORD FROM mysql.user; ```sql obclient> CREATE USER 'sqluser03' IDENTIFIED BY PASSWORD '******************';Query the users that you created.
obclient> SELECT user FROM mysql.user; +-----------+ | user | +-----------+ | root | | admin | | sqluser01 | | sqluser02 | | sqluser03 | +-----------+ 5 rows in set