25-grant.md 2.3 KB
Newer Older
1
---
2 3
sidebar_label: Permissions Management
title: Permissions Management
4 5
---

6
This document describes how to manage permissions in TDengine.
7

8
## Create a User
9 10

```sql
11
CREATE USER use_name PASS 'password';
12 13
```

14
This statement creates a user account.
15

16
The maximum length of use_name is 23 bytes.
17

18
The maximum length of password is 128 bytes. The password can include leters, digits, and special characters excluding single quotation marks, double quotation marks, backticks, backslashes, and spaces. The password cannot be empty.
19

20
## Delete a User
21 22 23 24 25

```sql
DROP USER user_name;
```

26
## Modify User Information
27 28 29 30 31 32 33 34 35 36 37

```sql
ALTER USER user_name alter_user_clause
 
alter_user_clause: {
    PASS 'literal'
  | ENABLE value
  | SYSINFO value
}
```

38 39 40
- PASS: Modify the user password.
- ENABLE: Specify whether the user is enabled or disabled. 1 indicates enabled and 0 indicates disabled.
- SYSINFO: Specify whether the user can query system information. 1 indicates that the user can query system information and 0 indicates that the user cannot query system information.
41 42


43
## Grant Permissions
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63

```sql
GRANT privileges ON priv_level TO user_name
 
privileges : {
    ALL
  | priv_type [, priv_type] ...
}
 
priv_type : {
    READ
  | WRITE
}
 
priv_level : {
    dbname.*
  | *.*
}
```

64
Grant permissions to a user.
65

66
Permissions are granted on the database level. You can grant read or write permissions.
67

68
TDengine has superusers and standard users. The default superuser name is root. This account has all permissions. You can use the superuser account to create standard users. With no permissions, standard users can create databases and have permissions on the databases that they create. These include deleting, modifying, querying, and writing to their own databases. Superusers can grant users permission to read and write other databases. However, standard users cannot delete or modify databases created by other users.
69

70
For non-database objects such as users, dnodes, and user-defined functions, standard users have read permissions only, generally by means of the SHOW statement. Standard users cannot create or modify these objects.
71

72
## Revoke Permissions
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93

```sql
REVOKE privileges ON priv_level FROM user_name
 
privileges : {
    ALL
  | priv_type [, priv_type] ...
}
 
priv_type : {
    READ
  | WRITE
}
 
priv_level : {
    dbname.*
  | *.*
}

```

94
Revoke permissions from a user.