IoTDB provides permission management capabilities to implement fine-grained access control for data and cluster systems, ensuring data and system security. This article introduces the core concepts of the permission module under the IoTDB Table Model, user specifications, permission governance, authentication logic, and practical use cases.
A user refers to a legitimate database operator. Each user corresponds to a unique username and is authenticated by a password. To use the database, users must provide valid usernames and passwords stored in the system.
The database supports a wide range of operations, but not all users are authorized to perform every action. A user is considered to have the corresponding privilege if permitted to execute a specific operation.
A role is a collection of privileges identified by a unique role name. Roles correspond to actual job identities (e.g., traffic dispatchers), and multiple users may share the same identity. Users with identical job roles usually require consistent permissions. Roles serve as an abstraction for unified permission management among user groups.
After initialization, IoTDB provides one default user named root with the default password root. As the administrator account, root owns all privileges permanently. Its permissions cannot be granted, revoked, or deleted, and it is the sole administrator user in the database. Newly created users and roles have no permissions by default.
Users with the SECURITY privilege can create users and roles, subject to the following constraints:
!@#$%^&*()_+-=). Creation of usernames identical to the administrator account is prohibited."" during creation.Passwords must be 4 to 32 characters long, including uppercase and lowercase letters, digits, and special symbols (!@#$%^&*()_+-=). A password cannot be the same as the associated username.
Role names must be 4 to 32 characters long, including uppercase and lowercase letters, digits, and special symbols (!@#$%^&*()_+-=). Creation of role names identical to the administrator account is prohibited.
Under the IoTDB Table Model, permissions are divided into two major categories: global privileges and data privileges.
Global privileges include two types: SYSTEM and SECURITY:
Detailed descriptions of each global privilege are shown in the table below:
Data privileges consist of privilege types and effective scopes.
CREATE, DROP, ALTER, SELECT, INSERT, DELETE.ANY (system-wide), DATABASE (database-level), TABLE (single table).ANY scope apply to all databases and tables.DATABASE1.TABLE1, the system checks write permissions in sequence for ANY, DATABASE1, and DATABASE1.TABLE1 until a matching privilege is found or the check fails.The logical relationship between privilege types, scopes and capabilities is shown below:
In IoTDB, user privileges can be granted or revoked through three methods:
GRANT OPTION privilege.SECURITY privileges.The following rules apply to privilege management under the IoTDB Table Model:
SECURITY privilege)CREATE USER <USERNAME> <PASSWORD> -- Example CREATE USER user1 'passwd'
SECURITY privilege.ALTER USER <USERNAME> SET PASSWORD <password> -- Example ALTER USER tempuser SET PASSWORD 'newpwd'
SECURITY privilege)DROP USER <USERNAME> -- Example DROP USER user1
SECURITY privilege)CREATE ROLE <ROLENAME> -- Example CREATE ROLE role1
SECURITY privilege)DROP ROLE <ROLENAME> -- Example DROP ROLE role1
SECURITY privilege)GRANT ROLE <ROLENAME> TO <USERNAME> -- Example GRANT ROLE admin TO user1
SECURITY privilege)REVOKE ROLE <ROLENAME> FROM <USERNAME> -- Example REVOKE ROLE admin FROM user1
SECURITY privilege)LIST USER
SECURITY privilege)LIST ROLE
SECURITY privilege)LIST USER OF ROLE <ROLENAME> -- Example LIST USER OF ROLE roleuser
SECURITY privilege.LIST ROLE OF USER <USERNAME> -- Example LIST ROLE OF USER tempuser
SECURITY privilege.LIST PRIVILEGES OF USER <USERNAME> -- Example LIST PRIVILEGES OF USER tempuser
SECURITY privilege.LIST PRIVILEGES OF ROLE <ROLENAME> -- Example LIST PRIVILEGES OF ROLE actor
GRANT SECURITY TO USER <USERNAME> -- Example GRANT SECURITY TO USER TEST_USER
GRANT CREATE ON DATABASE <DATABASE> TO USER <USERNAME> WITH GRANT OPTION -- Example GRANT CREATE ON DATABASE TESTDB TO USER TEST_USER WITH GRANT OPTION
GRANT SELECT ON DATABASE <DATABASE> TO ROLE <ROLENAME> -- Example GRANT SELECT ON DATABASE TESTDB TO ROLE TEST_ROLE
GRANT SELECT ON <DATABASE>.<TABLENAME> TO USER <USERNAME> -- Example GRANT SELECT ON TESTDB.TESTTABLE TO USER TEST_USER
GRANT SELECT ON ANY TO ROLE <ROLENAME> -- Example GRANT SELECT ON ANY TO ROLE TEST_ROLE
ALL represents all privileges within the target scope-- Grant all global privileges and full data privileges under ANY scope GRANT ALL TO USER TESTUSER -- Grant all data privileges under ANY scope GRANT ALL ON ANY TO USER TESTUSER -- Grant all data privileges under the specified database GRANT ALL ON DATABASE TESTDB TO USER TESTUSER -- Grant all data privileges under the specified table GRANT ALL ON TABLE TESTTABLE TO USER TESTUSER
REVOKE SECURITY FROM USER <USERNAME> -- Example REVOKE SECURITY FROM USER TEST_USER
REVOKE CREATE ON DATABASE <DATABASE> FROM USER <USERNAME> -- Example REVOKE CREATE ON DATABASE TEST_DB FROM USER TEST_USER
REVOKE SELECT ON <DATABASE>.<TABLENAME> FROM USER <USERNAME> -- Example REVOKE SELECT ON TESTDB.TESTTABLE FROM USER TEST_USER
REVOKE SELECT ON ANY FROM USER <USERNAME> -- Example REVOKE SELECT ON ANY FROM USER TEST_USER
-- Revoke all global privileges and ANY-scoped data privileges REVOKE ALL FROM USER TESTUSER -- Only revoke ANY-scoped data privileges REVOKE ALL ON ANY FROM USER TESTUSER -- Only revoke all data privileges of the specified database REVOKE ALL ON DATABASE TESTDB FROM USER TESTUSER -- Only revoke all data privileges of the specified table REVOKE ALL ON TABLE TESTDB FROM USER TESTUSER
Each user has an independent privilege list recording all authorized permissions. Use the following statement to query privilege details:
LIST PRIVILEGES OF USER <USERNAME>
Output format:
| ROLE | SCOPE | PRIVILEGE | WITH GRANT OPTION |
|---|---|---|---|
| DB1.TB1 | SELECT | FALSE | |
| SECURITY | TRUE | ||
| ROLE1 | DB2.TB2 | INSERT | TRUE |
| ROLE1 | DB3.* | DELETE | FALSE |
| ROLE1 | . | UPDATE | TRUE |
DB.TABLE, database-level scope as DB.*, and global ANY scope as *.*.TRUE means the user can regrant or revoke privileges within the corresponding scope.Note: Users and roles can hold permissions for both the Tree Model and Table Model simultaneously. The system only displays permissions applicable to the currently connected model, while permissions for the other model are hidden.
Based on the Sample Data, data in different tables belongs to two independent data centers (bj and sh). To ensure data isolation, cross-center data access needs to be restricted through permission control.
Use the CREATE USER statement to create new users. For example, the root administrator creates two dedicated write users for the BJ and SH data centers: bj_write_user and sh_write_user, with a unified password write_pwd.
CREATE USER bj_write_user 'write_pwd'; CREATE USER sh_write_user 'write_pwd';
Execute the user query statement:
LIST USER
Query result:
+------+-------------+-----------------+-----------------+ |UserId| User|MaxSessionPerUser|MinSessionPerUser| +------+-------------+-----------------+-----------------+ | 0| root| -1| 1| | 10000|bj_write_user| -1| -1| | 10001|sh_write_user| -1| -1| +------+-------------+-----------------+-----------------+
Newly created users have no permissions by default and cannot perform database operations. For example, an insertion executed by bj_write_user will fail:
INSERT INTO table1(region, plant_id, device_id, model_id, maintenance, time, temperature, humidity, status, arrival_time) VALUES ('Beijing', '1001', '100', 'A', '180', '2025-03-26 13:37:00', 190.0, 30.1, false, '2025-03-26 13:37:34')
Error message after switching to the target database:
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 803: Access Denied: DATABASE database1
Grant table write privileges to bj_write_user via the root account:
GRANT INSERT ON database1.table1 TO USER bj_write_user
Retry data insertion after switching databases:
IoTDB> use database1 Msg: The statement is executed successfully. IoTDB:database1> INSERT INTO table1(region, plant_id, device_id, model_id, maintenance, time, temperature, humidity, status, arrival_time) VALUES ('Beijing', '1001', '100', 'A', '180', '2025-03-26 13:37:00', 190.0, 30.1, false, '2025-03-26 13:37:34') Msg: The statement is executed successfully.
Use the REVOKE statement to reclaim granted permissions:
REVOKE INSERT ON database1.table1 FROM USER bj_write_user REVOKE INSERT ON database1.table2 FROM USER sh_write_user
After revocation, the user loses corresponding write permissions and will receive a permission denied error when attempting to write data again:
Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 803: Access Denied: No permissions for this operation, please add privilege INSERT ON database1.table1