Users
The user management syntax is available across all versions, but in the TDengine TSDB Community Edition, only basic features are functionally accessible. Advanced functionalities require the TDengine TSDB Enterprise Edition. To learn about and obtain comprehensive user management features, please contact the TDengine sales team.
Create User
CREATE USER user_name PASS 'password'
[SYSINFO {1|0}]
[CREATEDB {1|0}]
[ENABLE {1|0}]
[CHANGEPASS {2|1|0}]
[SESSION_PER_USER {value | DEFAULT | UNLIMITED}]
[CONNECT_TIME {value | DEFAULT | UNLIMITED}]
[CONNECT_IDLE_TIME {value | DEFAULT | UNLIMITED}]
[CALL_PER_SESSION {value | DEFAULT | UNLIMITED}]
[VNODE_PER_CALL {value | DEFAULT | UNLIMITED}]
[FAILED_LOGIN_ATTEMPTS {value | DEFAULT | UNLIMITED}]
[PASSWORD_LOCK_TIME {value | DEFAULT | UNLIMITED}]
[PASSWORD_LIFE_TIME {value | DEFAULT | UNLIMITED}]
[PASSWORD_GRACE_TIME {value | DEFAULT | UNLIMITED}]
[PASSWORD_REUSE_TIME {value | DEFAULT}]
[PASSWORD_REUSE_MAX {value | DEFAULT}]
[INACTIVE_ACCOUNT_TIME {value | DEFAULT | UNLIMITED}]
[ALLOW_TOKEN_NUM {value | DEFAULT | UNLIMITED}]
[HOST {ip | ip range} [, {ip | ip range}] ...]
[NOT_ALLOW_HOST {ip | ip range} [, {ip | ip range}] ...]
[ALLOW_DATETIME {time range} [, {time range}] ...]
[NOT_ALLOW_DATETIME {time range} [, {time range}] ...]
The username can be up to 23 bytes long.
The password must be between 8 and 255 characters long and include at least three types of characters from the following: uppercase letters, lowercase letters, numbers, and special characters. Special characters include ! @ # $ % ^ & * ( ) - _ + = [ ] { } : ; > < ? | ~ , ., and this requirement is able to be closed by adding enableStrongPassword 0 in taos.cfg, or by the following SQL:
alter all dnodes 'EnableStrongPassword' '0'
SYSINFOindicates whether the user can view system information.1means they can view,0means they have no permission to view. System information includes service configuration, dnode, vnode, storage, etc. The default value is1.CREATEDBindicates whether the user can create databases.1means they can create databases,0means they have no permission to create databases. The default value is0. // Supported starting from TDengine Enterprise version 3.3.2.0ENABLEindicates whether the user is enabled,1means enabled,0means disabled. A disabled user cannot connect to the database. The default value is1.CHANGEPASSindicate whether the use can or must change password,2means can change password,1means must change password,0means cannot change password. The default value is2. Support in Enterprise Edition v3.4.0.0 and above.SESSION_PER_USERThe maximum allowed simulaneous connections of the user. The default value is32, with a minimal of1, set toUNLIMITEDdisables the restriction. Support in Enterprise Edition v3.4.0.0 and above.CONNECT_TIMEThe maximum allowed duration for a single session in minutes. The default value is480, with a minimum of1, set toUNLIMITEDdisables the restriction. Support in Enterprise Edition v3.4.0.0 and above.CONNECT_IDLE_TIMEThe maximum allowed idle duration for a single session in minutes. The default value is30, with a minimum of1, set toUNLIMITEDdisables the restriction. Support in Enterprise Edition v3.4.0.0 and above.CALL_PER_SESSIONThe maximum allowed number of sub-calls per session. The default value is10, with a minimum of1, set toUNLIMITEDdisables the restriction. Support in Enterprise Edition v3.4.0.0 and above.VNODE_PER_CALLThe maximum number of vnodes that a single call can involve. The default value is-1, which means unlimited. Support in Enterprise Edition v3.4.0.0 and above.FAILED_LOGIN_ATTEMPTSThe number of allowed consecutive failed login attempts; the user will be locked after exceeding this limit. The default value is3, with a minimum of1, set toUNLIMITEDdisables the restriction. Support in Enterprise Edition v3.4.0.0 and above.PASSWORD_LOCK_TIMEThe unlock waiting time for the user when locked due to failed login attempts, in minutes. The default value is1440, with a minimum of1, set toUNLIMITEDmeans the user is locked for ever. Support in Enterprise Edition v3.4.0.0 and above.PASSWORD_LIFE_TIMEPassword validity period, in days. The default value is90, with a minimum of1, set toUNLIMITEDmeans never expire. Support in Enterprise Edition v3.4.0.0 and above.PASSWORD_GRACE_TIMEThe grace period after password expiration, in days. This is a buffer time allowing password changes, during this period, all operations other than password modification are prohibited. If the password is not changed within the grace period, the user will be locked. The default value is7, with a minimum of0, set toUNLIMITEDmeans never lock the user. Support in Enterprise Edition v3.4.0.0 and above.PASSWORD_REUSE_TIMEThe duration during which an old password cannot be reused, in days. A new password must comply with both thePASSWORD_REUSE_TIMEandPASSWORD_REUSE_MAXrestrictions. The default value is30, with a maximum of365and a minimum of0. Support in Enterprise Edition v3.4.0.0 and above.PASSWORD_REUSE_MAXThe number of password changes required before an old password can be reused. A new password must comply with both thePASSWORD_REUSE_TIMEandPASSWORD_REUSE_MAXrestrictions. The default value is5, with a maximum of100and a minimum of0. Support in Enterprise Edition v3.4.0.0 and above.INACTIVE_ACCOUNT_TIMEUser inactivity lockout period, in days. The default value is90, with a minimum of1, set toUNLIMITEDmeans never lockout the user. Support in Enterprise Edition v3.4.0.0 and above.ALLOW_TOKEN_NUMThe maximum allowed number of tokens. The default value is3, with a minimum of0, set toUNLIMITEDdisables this restriction. Support in Enterprise Edition v3.4.0.0 and above.HOSTandNOT_ALLOW_HOSTIP address whitelist and blacklist. Entries can be a single IP address, such as192.168.1.1, or a subnet range in CIDR format, such as192.168.1.1/24. Support in Enterprise Edition v3.4.0.0 and above.- The whitelist/blacklist will only take effect when
enableWhiteListis set to1in the configuration. - If neither
HOSTnorNOT_ALLOW_HOSTis set, the user is allowed to log in from any address. Note: For security and convenience, ifHOSTis set or neitherHOSTnorNOT_ALLOW_HOSTis set during user creation, the system automatically adds127.0.0.1and::1toHOST. Therefore, the scenario described in this section can only occur when allHOSTandNOT_ALLOW_HOSTentries are dropped viaALTER USER. - If only
HOSTis set, the user is allowed to log in from that addresses or subnet ranges, and login from other addresses is not allowed. - If only
NOT_ALLOW_HOSTis set, the user is not allowed to log in from that addresses or subnet ranges, but login from other addresses is allowed. - If both
HOSTandNOT_ALLOW_HOSTare set, the user can only log in from addresses that belong toHOSTand do not belong toNOT_ALLOW_HOST. Login from any other address is not allowed.
- The whitelist/blacklist will only take effect when
ALLOW_DATETIMEandNOT_ALLOW_DATETIMEPermitted and prohibited login time ranges based on the server's local time zone. A valid time range consists of three parts: date, start time (accurate to the minute), and duration (in minutes). The date can be a specific date or represented by MON, TUE, WED, THU, FRI, SAT, SUN, for example:2025-12-25 08:00 120,TUE 08:00 120. Support in Enterprise Edition v3.4.0.0 and above.- If neither
ALLOW_DATETIMEnorNOT_ALLOW_DATETIMEis set, the user is allowed to log in at any time. - If only
ALLOW_DATETIMEis set, the user is allowed to log in during that time periods, and login at other times is not allowed. - If only
NOT_ALLOW_DATETIMEis set, the user is not allowed to log in during that time periods, but login at other times is allowed. - If both
ALLOW_DATETIMEandNOT_ALLOW_DATETIMEare set, the user can only log in during time periods that belong toALLOW_DATETIMEand do not belong toNOT_ALLOW_DATETIME. Login at any other time is not allowed.
- If neither
In the example below, we create a user with the password abc123!@# who can view system information.
taos> create user test pass 'abc123!@#' sysinfo 1;
Query OK, 0 of 0 rows affected (0.001254s)
View Users
You can use the following command to view the users in the system.
SHOW USERS;
Here is an example:
taos> show users;
name | super | enable | sysinfo | createdb | create_time | totp | allowed_host | allowed_datetime |
============================================================================================================================================
test | 0 | 1 | 1 | 0 | 2025-12-24 18:56:20.709 | 0 | +127.0.0.1/32, +::1/128 | +ALL |
root | 1 | 1 | 1 | 1 | 2025-12-24 18:00:43.197 | 0 | +127.0.0.1/32, +::1/128 | +ALL |
Query OK, 2 rows in set (0.001657s)
Note that in allowed_host, if an address or subnet range is prefixed with +, it indicates a whitelist entry, allowing login from that address. If prefixed with -, it indicates a blacklist entry, disallowing login from that address. The same rule applies to allowed_datetime.
Alternatively, you can query the built-in system table INFORMATION_SCHEMA.INS_USERS to get user information.
taos> select * from information_schema.ins_users;
name | super | enable | sysinfo | createdb | create_time | totp | allowed_host | allowed_datetime |
============================================================================================================================================
test | 0 | 1 | 1 | 0 | 2025-12-24 18:56:20.709 | 0 | +127.0.0.1/32, +::1/128 | +ALL |
root | 1 | 1 | 1 | 1 | 2025-12-24 18:00:43.197 | 0 | +127.0.0.1/32, +::1/128 | +ALL |
Query OK, 2 row(s) in set (0.007383s)
Delete User
DROP USER [IF EXISTS] user_name;
Modify User Configuration
ALTER USER user_name alter_user_clause
alter_user_clause: {
[PASS 'password']
[SYSINFO {1|0}]
[CREATEDB {1|0}]
[ENABLE {1|0}]
[CHANGEPASS {2|1|0}]
[SESSION_PER_USER {value | DEFAULT | UNLIMITED}]
[CONNECT_TIME {value | DEFAULT | UNLIMITED}]
[CONNECT_IDLE_TIME {value | DEFAULT | UNLIMITED}]
[CALL_PER_SESSION {value | DEFAULT | UNLIMITED}]
[VNODE_PER_CALL {value | DEFAULT | UNLIMITED}]
[FAILED_LOGIN_ATTEMPTS {value | DEFAULT | UNLIMITED}]
[PASSWORD_LOCK_TIME {value | DEFAULT | UNLIMITED}]
[PASSWORD_LIFE_TIME {value | DEFAULT | UNLIMITED}]
[PASSWORD_GRACE_TIME {value | DEFAULT | UNLIMITED}]
[PASSWORD_REUSE_TIME {value | DEFAULT}]
[PASSWORD_REUSE_MAX {value | DEFAULT}]
[INACTIVE_ACCOUNT_TIME {value | DEFAULT | UNLIMITED}]
[ALLOW_TOKEN_NUM {value | DEFAULT | UNLIMITED}]
[ADD HOST {ip | ip range} [, {ip | ip range}] ...]
[DROP HOST {ip | ip range} [, {ip | ip range}] ...]
[ADD NOT_ALLOW_HOST {ip | ip range} [, {ip | ip range}] ...]
[DROP NOT_ALLOW_HOST {ip | ip range} [, {ip | ip range}] ...]
[ADD ALLOW_DATETIME {time range} [, {time range}] ...]
[DROP ALLOW_DATETIME {time range} [, {time range}] ...]
[ADD NOT_ALLOW_DATETIME {time range} [, {time range}] ...]
[DROP NOT_ALLOW_DATETIME {time range} [, {time range}] ...]
}
The following example disables the user named test:
taos> alter user test enable 0;
Query OK, 0 of 0 rows affected (0.001160s)
TOTP Two-Factor Authentication
TOTP Two-Factor Authentication is a feature of TDengine TSDB Enterprise Edition, support in version v3.4.0.1 and above.
Create/Update TOTP secret
CREATE TOTP_SECRET FOR USER user_name
If the user has not yet created a TOTP secret, this command will create a TOTP secret for the user. If the user has already created a TOTP secret, this command will update the secret for the user. In either case, this command will return the newly created secret, which will only be displayed once, please save it promptly. The system will automatically enable TOTP two-factor authentication for users who have a TOTP secret.
After enabling TOTP two-factor authentication, TDengine TSDB requires the OTP to be 6 digits long and updated every 30 seconds. Please ensure to configure your TOTP generator according to these parameters; otherwise, clients may fail to log in.
For example, we can use the following command to create a TOTP secret for user test.
taos> create totp_secret for user test;
totp_secret |
=======================================================
ERIRPLZL4ZBFTPT5BNXMVFPR4Z3PTHUWTBTCNZPOHYPYQGTD25XA |
Query OK, 1 row(s) in set (0.002314s)
Drop TOTP Secret
DROP TOTP_SECRET FROM USER user_name
This command drops the TOTP secret from the user. After the secret is dropped, the user's TOTP two‑factor authentication will be disabled.
For example, we can use the following command to drop the TOTP key from user test.
taos> drop totp_secret from user test;
Drop OK, 0 row(s) affected (0.002295s)
Token Management
Token management is a feature of TDengine TSDB Enterprise Edition, support in version v3.4.0.0 and above.
Create Token
CREATE TOKEN [IF NOT EXISTS] token_name FROM USER user_name [ENABLE {1|0}] [TTL value] [PROVIDER value] [EXTRA_INFO value]
The token_name can be up to 31 bytes long.
ENABLEindicates whether the token is enabled,1means enabled,0means disabled. A disabled token cannot be used to connect the database. The default value is1.TTLvalidity period in days,0means always valid.PROVIDERname of the token provider, can be up to 63 bytes long.EXTRA_INFOAdditional information managed by applications, can be up to 1023 bytes long.
In the following example, we create a token named test_token for the user test. Please save the token value promptly as it is only displayed once upon creation—and cannot be queried thereafter.
taos> create token test_token from user test;
token |
==================================================================
BsyjYKxhCMntZ3pHgweCd2uV2C8HoGKn8Mvd49dRRCtzusX0P1mgqRMrG7SzUca |
Query OK, 1 row(s) in set (0.003018s)
View Tokens
You can use the following command to view tokens in the system, but depending on your privilege, you may only see tokens of your own.
SHOW TOKENS;
For example:
taos> show tokens;
name | user | provider | enable | create_time | expire_time | extra_info |
=========================================================================================================
root_token | root | | 1 | 2025-12-25 10:02:28.000 | 1970-01-01 08:00:00.000 | |
test_token | test | | 1 | 2025-12-25 10:01:47.000 | 1970-01-01 08:00:00.000 | |
Query OK, 2 row(s) in set (0.003313s)
Alternatively, you can query the built-in system table INFORMATION_SCHEMA.INS_TOKENS to get user information.
taos> select * from information_schema.ins_tokens;
name | user | provider | enable | create_time | expire_time | extra_info |
=========================================================================================================
root_token | root | | 1 | 2025-12-25 10:02:28.000 | 1970-01-01 08:00:00.000 | |
test_token | test | | 1 | 2025-12-25 10:01:47.000 | 1970-01-01 08:00:00.000 | |
Query OK, 2 row(s) in set (0.007438s)
Modify Token
ALTER TOKEN token_name [ENABLE {1|0}] [TTL value] [PROVIDER value] [EXTRA_INFO value]
When modify the validity period (TTL), new validity period starts from the time of modification.
Drop Token
DROP TOKEN [IF EXISTS] token_name;
Note that when drop a user, tokens of the user will be cascade deleted simultaneously.