This topic describes how to create an OceanBase database user.
Create users in MySQL mode and Oracle mode by using SQL statements
MySQL mode
The user management syntax tree in MySQL mode is as follows:
create_user_stmt: CREATE USER [IF NOT EXISTS] user_name [IDENTIFIED BY 'password']; alter_user_stmt: ALTER USER user_name ACCOUNT {LOCK | UNLOCK}; | ALTER USER user_name IDENTIFIED BY 'password'; | SET PASSWORD [FOR user_name] = PASSWORD('password'); | RENAME USER rename_user_action_list; drop_user_stmt: DROP USER user_name_list; rename_user_action_list: rename_user_action [, rename_user_action ...] rename_user_action: user_name TO user_name user_name_list: user_name [, user_name ...] password: STR_VALUEThe following example statement creates users
sqluser01andsqluser02whose passwords are*****in MySQL mode:obclient> CREATE USER 'sqluser01' IDENTIFIED BY '******', 'sqluser02' IDENTIFIED BY '*****';For more information about the
CREATE USERstatement in MySQL mode, see CREATE USER.Oracle mode
The user management syntax tree in Oracle mode is as follows:
create_user_stmt: CREATE USER user_name [host_name] IDENTIFIED BY password [REQUIRE {NONE | SSL | X509 | tls_option_list}] [PROFILE user_profile] [DEFAULT TABLESPACE table_space] password: STR_VALUE tls_option_list: tls_option | tls_option_list, tls_option alter_user_stmt: ALTER USER user_name ACCOUNT {LOCK | UNLOCK}; | ALTER USER user_name IDENTIFIED BY password; | SET PASSWORD [FOR user_name] = PASSWORD(password); drop_user_stmt: DROP USER user cascade;The following example statement creates user
sqluserwhose password is******in Oracle mode:obclient> CREATE USER sqluser IDENTIFIED BY ******;For more information about the
CREATE USERstatement in Oracle mode, see CREATE USER.