该语句用于创建新的 OceanBase 用户。创建新用户后,可以使用该用户连接 OceanBase。
说明
必须拥有全局的 CREATE USER 权限,才可以使用 CREATE USER 命令。
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_VALUE
CREATE USER [IF NOT EXISTS] user_specification_list;
user_specification_list:
user_specification [, user_specification ...]
user_specification:
user IDENTIFIED BY ‘authstring’
| user IDENTIFIED BY PASSWORD ‘hashstring’
参数 | 描述 |
---|---|
user_name | 用户名,新建用户后,“mysql.user”表会新增一行该用户的表项。如果同名用户已经存在,则报错。 |
IDENTIFIED BY | 使用自选的 IDENTIFIED BY 子句,可以为账户给定一个密码。 |
user_name [, user_name ...] | 同时创建多个用户时,用“,”隔开。 |
user IDENTIFIED BY ‘authstring’ | 此处密码为明文,存入“mysql.user”表后,服务器端会变为密文存储下来。 |
user IDENTIFIED BY PASSWORD ‘hashstring’ | 此处密码为密文。 |
CREATE USER 'sqluser01' IDENTIFIED BY '123456', 'sqluser02' IDENTIFIED BY '123456';
SELECT user FROM mysql.user;
执行结果如下所示。
mysql> CREATE USER 'sqluser01' IDENTIFIED BY '123456', 'sqluser02' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.12 sec)
mysql> select user from mysql.user;
+-----------+
| user |
+-----------+
| root |
| admin |
| sqluser01 |
| sqluser02 |
+-----------+
4 rows in set (0.00 sec)
备案信息: 粤ICP备15087711号-2
Copyright © 2008-2024 啊嘎哇在线工具箱 All Rights.
本站所有资料来源于网络,版权归原作者所有,仅作学习交流使用,如不慎侵犯了您的权利,请联系我们。