Description
The CREATE USER statement is used to create a new OceanBase AI Database user. After creating a new user, you can use the new user to connect to OceanBase AI Database.
Privilege requirements
To execute the CREATE USER statement, you must have the global CREATE USER privilege. For more information about OceanBase AI Database privileges, see Permission classification.
Syntax
CREATE USER [IF NOT EXISTS] {user [, user...]}
[REQUIRE {NONE | SSL | X509 | tls_option}]
[WITH resource_option [resource_option...]];
user:
user_name
| user_name IDENTIFIED [WITH auth_plugin] BY password
| user_name IDENTIFIED [WITH auth_plugin] BY PASSWORD password
| user_name IDENTIFIED [WITH auth_plugin] AS PASSWORD 'auth_string'
tls_option:
CIPHER cipher_name
| ISSUER issuer_name
| SUBJECT subject_name
resource_option:
MAX_CONNECTIONS_PER_HOUR integer
| MAX_USER_CONNECTIONS integer
Parameters
Parameter |
Description |
|---|---|
| IF NOT EXISTS | It indicates that if the username already exists, the user will not be created. When creating a user, if the specified username already exists and the IF NOT EXISTS, an error will be reported. |
| user_name | Username. After the user is created, a new row for the user is added to the mysql.user table. When creating multiple users at the same time, separate the names with commas (,). |
| auth_plugin | Specifies the user authentication method. Currently, only mysql_native_password Authentication plugins. |
| IDENTIFIED BY password | Create a password for the user to be created. The password is stored in plaintext here. mysql.user After the table, the password is stored as ciphertext on the server side. If the password contains special characters ~!@#%^&*_-+=`| (){}[]:;',.?/ must be enclosed in English quotation marks (' or "). |
| IDENTIFIED BY PASSWORD password | Create a password for the user to be created. The password is stored in ciphertext format and will be directly stored in the database. mysql.user Table. |
| IDENTIFIED AS PASSWORD | Set the account authentication plugin to auth_plugin and store the auth_string value in the mysql.user table. If the plugin requires a hash string, it is assumed that the string is already in the hash format required by the plugin. |
| REQUIRE | Specifies the password verification requirements for a user. Valid values:
|
| tls_option | Specifies the specific options for TLS requirements.
|
| resource_option | Resource options for a specified user. Separate multiple resource options with spaces.
|
Examples
Create users test1 and test2, specify their plaintext passwords, and set the maximum number of connections allowed per user.
obclient> CREATE USER IF NOT EXISTS test1 IDENTIFIED BY '********', test2 IDENTIFIED BY '********' WITH MAX_USER_CONNECTIONS 10;Create a user named test3, specify a ciphertext password, and require SSL connection authentication.
obclient> CREATE USER IF NOT EXISTS test3 IDENTIFIED BY PASSWORD '********' REQUIRE SSL;Create a user named test4 and specify to use the mysql_native_password authentication plugin.
obclient> CREATE USER IF NOT EXISTS test4 IDENTIFIED WITH mysql_native_password BY PASSWORD '********';
References
For more information about granting user privileges, see Grant privileges directly.
You can view the information about the created user in the
mysql.usertable. For more information about themysql.usertable, see mysql.user.For information about how to connect to OceanBase AI Database using the created user, see Overview of connection methods.