赞
踩
本文主要讲述数据库用户管理和用户权限管理。
数据库的第一个账号(用户)毫无疑问是root,root账号(用户)拥有所有权限。
对于root账号(用户)我们只需要做好密码管理功能。
一个数据库可能被多个应用使用,那么就需要分配不同的账号(用户)给不同的应用。
不同应用可读写的数据权限范围也不一样,所以需要按需授权和撤销授权。
当某个应用下线不再使用时,该应用对应的数据库账号(用户)也需要及时删除。
ALTER USER SET PASSWORD ‘password’;
[root@iZ2ze30dygwd6yh7gu6lskZ apache-iotdb-1.3.1-all-bin]# bash sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root --------------------- Starting IoTDB Cli --------------------- _____ _________ ______ ______ |_ _| | _ _ ||_ _ `.|_ _ \ | | .--.|_/ | | \_| | | `. \ | |_) | | | / .'`\ \ | | | | | | | __'. _| |_| \__. | _| |_ _| |_.' /_| |__) | |_____|'.__.' |_____| |______.'|_______/ version 1.3.1 (Build: 214695d) Successfully login at 127.0.0.1:6667 IoTDB> ALTER USER root SET PASSWORD '1234567890'; Msg: The statement is executed successfully. IoTDB> exit [root@iZ2ze30dygwd6yh7gu6lskZ apache-iotdb-1.3.1-all-bin]# bash sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw 1234567890 --------------------- Starting IoTDB Cli --------------------- _____ _________ ______ ______ |_ _| | _ _ ||_ _ `.|_ _ \ | | .--.|_/ | | \_| | | `. \ | |_) | | | / .'`\ \ | | | | | | | __'. _| |_| \__. | _| |_ _| |_.' /_| |__) | |_____|'.__.' |_____| |______.'|_______/ version 1.3.1 (Build: 214695d) Successfully login at 127.0.0.1:6667 IoTDB>
bash sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw 1234567890
[root@iZ2ze30dygwd6yh7gu6lskZ apache-iotdb-1.3.1-all-bin]# bash sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw 1234567890
---------------------
Starting IoTDB Cli
---------------------
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version 1.3.1 (Build: 214695d)
Successfully login at 127.0.0.1:6667
IoTDB>
LIST USER
IoTDB> LIST USER
+-----+
| user|
+-----+
| root|
|user1|
+-----+
Total line number = 2
It costs 0.004s
CREATE USER user1 ‘12345678’
IoTDB> CREATE USER user1 '12345678'
Msg: The statement is executed successfully.
DROP USER user1;
IoTDB> DROP USER user1
Msg: The statement is executed successfully.
ALTER USER user1 SET PASSWORD ‘88888888’
IoTDB> ALTER USER user1 SET PASSWORD '88888888'
Msg: The statement is executed successfully.
权限名称 | 权限范围 |
---|---|
ALL | 所有权限 |
READ | READ_SCHEMA、READ_DATA |
WRITE | WRITE_SCHEMA、WRITE_DATA |
LIST PRIVILEGES OF USER user1
IoTDB> LIST PRIVILEGES OF USER user1
+----+----+----------+------------+
|ROLE|PATH|PRIVILEGES|GRANT OPTION|
+----+----+----------+------------+
+----+----+----------+------------+
Empty set.
It costs 0.003s
GRANT READ_DATA,WRITE_DATA ON root.user1.** TO USER user1 WITH GRANT OPTION;
IoTDB> GRANT READ_DATA,WRITE_DATA ON root.user1.** TO USER user1 WITH GRANT OPTION;
Msg: The statement is executed successfully.
IoTDB> LIST PRIVILEGES OF USER user1
+----+-------------+----------+------------+
|ROLE| PATH|PRIVILEGES|GRANT OPTION|
+----+-------------+----------+------------+
| |root.user1.**| READ_DATA| true|
| |root.user1.**|WRITE_DATA| true|
+----+-------------+----------+------------+
Total line number = 2
It costs 0.004s
REVOKE WRITE_DATA ON root.user1.** FROM USER user1
IoTDB> REVOKE WRITE_DATA ON root.user1.** FROM USER user1
Msg: The statement is executed successfully.
IoTDB> LIST PRIVILEGES OF USER user1
+----+-------------+----------+------------+
|ROLE| PATH|PRIVILEGES|GRANT OPTION|
+----+-------------+----------+------------+
| |root.user1.**| READ_DATA| true|
+----+-------------+----------+------------+
Total line number = 1
It costs 0.006s
觉得好,就一键三连呗(点赞+收藏+关注)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。