命令
本主题主要介绍 VectorDB CLI 所支持的命令和相应选项,包括一些示例供您参考。
命令参考
在成功连接 VectorDB Server 后,开始操作数据库。
Database 操作
创建数据库
描述
创建数据库
命令
create database
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > create database -d testdb
create database 'testdb' success
vectordb-cli >
查询库列表
描述
列出当前连接下所有的数据库
命令
list databases
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > list databases
+--------------+
| databases |
+==============+
| testdb |
+--------------+
vectordb-cli >
删除数据库
描述
删除指定的数据库
命令
drop database
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > drop database -d testdb
drop database 'testdb' success
vectordb-cli >
vectordb-cli > list databases
no databases found
vectordb-cli >
Table 操作
创建表
描述
在指定的库中新建一个表
命令
create table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定json文件来输入参数,建表需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json作为参数来建表,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
vectordb-cli > create table
input create table args, end with ';'
...
... {
... "database": "testdb",
... "table": "book",
... "description": "basic test",
... "replication": 1,
... "partition": {
... "partitionType": "HASH",
... "partitionNum": 3
... },
... "enableDynamicField": false,
... "schema": {
... "fields": [
... {
... "fieldName": "id",
... "fieldType": "STRING",
... "primaryKey": true,
... "partitionKey": true,
... "autoIncrement": false,
... "notNull": true
... },
... {
... "fieldName": "bookName",
... "fieldType": "STRING",
... "notNull": true
... },
... {
... "fieldName": "author",
... "fieldType": "STRING"
... },
... {
... "fieldName": "page",
... "fieldType": "UINT32"
... },
... {
... "fieldName": "content",
... "fieldType": "TEXT",
... "notNull": true
... },
... {
... "fieldName": "tags",
... "fieldType": "ARRAY",
... "elementType": "STRING",
... "maxCapacity": 1024
... },
... {
... "fieldName": "vector",
... "fieldType": "FLOAT_VECTOR",
... "notNull": true,
... "dimension": 3
... }
... ],
... "indexes": [
... {
... "indexName": "book_name_idx",
... "field": "bookName",
... "indexType": "SECONDARY"
... },
... {
... "indexName": "vector_idx",
... "field": "vector",
... "indexType": "HNSW",
... "metricType": "L2",
... "params": {
... "M": 32,
... "efConstruction": 32
... },
... "autoBuild": true,
... "autoBuildPolicy": {
... "policyType": "ROW_COUNT_INCREMENT",
... "rowCountIncrement": 10000
... }
... },
... {
... "indexName": "content_inverted_index",
... "indexType": "INVERTED",
... "fields": ["content"],
... "fieldsIndexAttributes": ["ATTRIBUTE_ANALYZED"],
... "params": {
... "analyaer": "DEFAULT_ANALYZER",
... "parseMode": "COARSE_MODE"
... }
... },
... {
... "indexName": "title_index",
... "indexType": "FILTERING",
... "fields": [
... {
... "field": "@SCALAR",
... "indexStructureType": "BITMAP"
... },
... {
... "field": "title",
... "indexStructureType": "DEFAULT"
... }
... ]
... }
... ]
... }
... }
... ;
create table 'book' success
vectordb-cli >
示例2,通过指定json文件来输入参数
下面createTable.json中的内容与上面例子中的json一致。
vectordb-cli > create table -f ./example/table/createTable.json
create table 'book' success
vectordb-cli >
vectordb-cli >
列出所有表
描述
列出指定数据库下所有的表
命令
list tables
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > list tables -d testdb
+-----------+
| tables |
+===========+
| book |
+-----------+
| book2 |
+-----------+
vectordb-cli >
删除表
描述
删除指定的表
命令
drop table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > drop table -d testdb -t book2
drop table 'book2' success
vectordb-cli >
vectordb-cli > list tables -d testdb
+-----------+
| tables |
+===========+
| book |
+-----------+
vectordb-cli >
vectordb-cli >
获取表的统计信息
描述
获取表的统计信息
命令
stats table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > stats table -d testdb -t book
+-------------+---------------------+-------------------+
| rowCount | memorySizeInByte | diskSizeInByte |
+=============+=====================+===================+
| 0 | 2232 | 0 |
+-------------+---------------------+-------------------+
vectordb-cli >
查询表详情
描述
查询指定表的详情
命令
describe table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > describe table -d testdb -t book
table 'book' description:
{
"database": "testdb",
"table": "book",
"createTime": "2024-09-14 11:37:57",
"description": "basic test",
"replication": 1,
"partition": {
"partitionType": "HASH",
"partitionNum": 3
},
"enableDynamicField": false,
"state": "NORMAL",
"schema": {
"fields": [
{
"primaryKey": true,
"partitionKey": true,
"autoIncrement": false,
"notNull": true,
"fieldName": "id",
"fieldType": "STRING"
},
{
"fieldName": "bookName",
"fieldType": "STRING",
"primaryKey": false,
"partitionKey": false,
"autoIncrement": false,
"notNull": true
},
{
"autoIncrement": false,
"notNull": false,
"fieldName": "author",
"fieldType": "STRING",
"primaryKey": false,
"partitionKey": false
},
{
"primaryKey": false,
"partitionKey": false,
"autoIncrement": false,
"notNull": false,
"fieldName": "page",
"fieldType": "UINT32"
},
{
"fieldName": "vector",
"fieldType": "FLOAT_VECTOR",
"dimension": 3,
"primaryKey": false,
"partitionKey": false,
"autoIncrement": false,
"notNull": true
}
],
"indexes": [
{
"indexName": "book_name_idx",
"indexType": "SECONDARY",
"field": "bookName",
"state": "NORMAL"
},
{
"indexName": "vector_idx",
"indexType": "HNSW",
"metricType": "L2",
"params": {
"M": 32,
"efConstruction": 32
},
"field": "vector",
"state": "INVALID"
}
]
}
}
vectordb-cli >
新增表字段
描述
在指定表中新增一个字段,当前仅支持新增标量、向量字段。
命令
add field
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定读取特定文件中的json,新增字段需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json作为参数来新增字段,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
vectordb-cli > add field
input add field args, end with ';'
...
... {
... "database": "testdb",
... "table": "book",
... "schema": {
... "fields": [
... {
... "fieldName": "scalar2",
... "fieldType": "STRING"
... },
... {
... "fieldName": "vector2",
... "fieldType": "FLOAT_VECTOR",
... "dimension": 3
... }
... ]
... }
... }
... ;
add field success.
vectordb-cli >
示例2,通过指定json文件来输入参数
vectordb-cli > add field -f ./example/table/addField.json
add field success.
vectordb-cli >
使用 describe table
检查新增的标量字段。
vectordb-cli > describe table -d testdb -t book
table 'book' description:
{
"database": "testdb",
"table": "book",
... ...
"schema": {
"fields": [
... ...
{
"partitionKey": false,
"autoIncrement": false,
"notNull": false,
"fieldName": "scalar2",
"fieldType": "STRING",
"primaryKey": false
},
{
"fieldName": "scalar1",
"fieldType": "STRING",
"primaryKey": false,
"partitionKey": false,
"autoIncrement": false,
"notNull": false
}
]
... ...
}
}
vectordb-cli >
给表添加别名
描述
给指定的表添加别名
命令
alias table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-a | --alias | 是 | 要添加的别名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > alias table -d testdb -t book -a book_alias
alias table success.
vectordb-cli >
`查看表的详情,aliases中有新增的 book_alias`
vectordb-cli > describe table -d testdb -t book
table 'book_segments' description:
{
"database": "testdb",
"table": "book",
... ...
"enableDynamicField": false,
"state": "NORMAL",
"aliases": [
"book_alias"
],
"schema": {
"fields": [
{
vectordb-cli >
vectordb-cli >
给表移除别名
描述
给指定的表移除别名
命令
unalias table
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-a | --alias | 是 | 要移除的别名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > unalias table -d testdb -t book -a book_alias
unalias table success.
vectordb-cli >
vectordb-cli >
vectordb-cli >
Index 操作
查询索引详情
描述
查询指定索引的详情
命令
describe index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-i | --index | 是 | 索引名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > describe index -d testdb -t book -i vector_idx
index 'vector_idx' description:
{
"indexName": "vector_idx",
"indexType": "HNSW",
"metricType": "L2",
"params": {
"M": 32,
"efConstruction": 32
},
"field": "vector",
"state": "INVALID"
}
删除索引
描述
删除指定索引
命令
drop index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-i | --index | 是 | 索引名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > drop index -d testdb -t book -i vector_idx
drop index 'vector_idx' success
vectordb-cli >
vectordb-cli > describe index -d testdb -t book -i vector_idx
desc index 'vector_idx' failed, [Code: 91; Message: Index Not Found; RequestId: 43cb102a-7361-4987-b451-dfe36115f08a]
vectordb-cli >
vectordb-cli >
创建索引
描述
为指定表和字段新建索引,当前仅支持新建向量索引。支持同时建立多个索引(针对不同字段)。
命令
create index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定读取特定文件中的json,创建索引需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json作为参数来创建索引,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
vectordb-cli > create index
input create index args, end with ';'
...
... {
... "database": "testdb",
... "table": "book",
... "indexes": [
... {
... "field": "vector",
... "indexName": "vector_idx",
... "indexType": "HNSW",
... "metricType": "L2",
... "params": {
... "M": 32,
... "efConstruction": 200
... }
...
... }
... ]
... }
... ;
create indexes for table 'book' success
vectordb-cli >
`查看新建的索引`
vectordb-cli >
vectordb-cli > describe index -d testdb -t book -i vector_idx
index 'vector_idx' description:
{
"indexName": "vector_idx",
"indexType": "HNSW",
"metricType": "L2",
"params": {
"M": 32,
"efConstruction": 200
},
"field": "vector",
"state": "INVALID"
}
vectordb-cli >
示例2,通过指定json文件来输入参数
vectordb-cli > create index -f ./example/index/createIndex.json
create indexes for table 'book' success
vectordb-cli >
修改索引
描述
修改向量索引信息,目前只支持修改autoBuild属性。
命令
modify index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定读取特定文件中的json,修改索引需要的json详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个json 作为参数来修改索引,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数
示例1,控制台输入json参数
vectordb-cli > modify index
input modify index args, end with ';'
...
... {
... "database": "book",
... "table": "book_segments",
... "index": {
... "indexName": "vector_idx",
... "autoBuild": true,
... "autoBuildPolicy": {
... "policyType": "timing",
... "timing": "2024-10-01 12:00:00"
... }
... }
... }
...
... ;
modify index 'vector_idx' success
vectordb-cli >
vectordb-cli >
`查看修改后的索引`
vectordb-cli >
vectordb-cli > describe index -d testdb -t book -i vector_idx
index 'vector_idx' description:
{
"indexName": "vector_idx",
"indexType": "HNSW",
"metricType": "L2",
"params": {
"M": 32,
"efConstruction": 200
},
"field": "vector",
"state": "INVALID",
"autoBuild": true,
"autoBuildPolicy": {
"policyType": "timing",
"timing": "2024-10-01 12:00:00"
}
}
vectordb-cli >
示例2,通过指定json文件来输入参数
vectordb-cli > modify index -f ./example/index/modifyIndex.json
modify index 'vector_idx' success
vectordb-cli >
重建索引
描述
重建指定索引,仅支持重建向量索引。
命令
rebuild index
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-d | --db | 是 | 数据库名 |
-t | --table | 是 | 表名 |
-i | --index | 是 | 索引名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > rebuild index -d testdb -t book -i vector_idx
rebuild index 'vector_idx' success
vectordb-cli >
`重建索引后,可以看到,索引的状态从 INVALID 转为 BUILDING, 最后转为 NORMAL`
vectordb-cli >
vectordb-cli > describe index -d testdb -t book -i vector_idx
index 'vector_idx' description:
{
"indexName": "vector_idx",
"indexType": "HNSW",
"metricType": "L2",
"params": {
"M": 32,
"efConstruction": 200
},
"field": "vector",
"state": "BUILDING"
}
vectordb-cli >
vectordb-cli > describe index -d testdb -t book -i vector_idx
index 'vector_idx' description:
{
"indexName": "vector_idx",
"indexType": "HNSW",
"metricType": "L2",
"params": {
"M": 32,
"efConstruction": 200
},
"field": "vector",
"state": "NORMAL"
}
Role 操作
创建角色
描述
创建一个新的角色
命令
create role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-r | --role | 是 | 角色名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > create role -r writable
create role 'writable' success
vectordb-cli >
删除角色
描述
删除指定的角色
命令
drop role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-r | --role | 是 | 角色名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > drop role -r writable
Drop role writable ? (y/N) y
drop role 'writable' success
vectordb-cli >
授权角色以权限
描述
将指定的一个或多个权限元组(Privilege Tuple)授权给指定的角色。支持同时授权具体的权限和权限组(Privilege Group)。
命令
grant role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来授权角色以权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
vectordb-cli > grant role privilege
input grant role privilage args, end with ';'
...
... {
... "role": "writable",
... "privilegeTuples": [
... {
... "database": "*",
... "table": "*",
... "privileges": ["QUERY", "SELECT", "SEARCH"]
... },
... {
... "database": "testdb",
... "table": "book",
... "privileges": ["TABLE_CONTROL", "TABLE_READWRITE"]
... }
... ]
... }
... ;
grant role 'writable' privileges success
vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 grantRolePrivileges.json 中的内容与上面例子中的 json 一致。
vectordb-cli > grant role privilege -f ./example/role/grantRolePrivileges.json
grant role 'writable' privileges success
vectordb-cli >
展示角色的权限
描述
展示指定角色的所有权限,以及被授权到的用户列表
命令
show role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-r | --role | 是 | 角色名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > show role privilege -r writable
{
"privilegeTuples": [
{
"database": "*",
"table": "*",
"privileges": [
"QUERY",
"SELECT",
"SEARCH"
]
},
{
"database": "testdb",
"table": "book",
"privileges": [
"CREATE_TABLE",
"DROP_TABLE",
"SHOW_TABLE",
"QUERY",
"SELECT",
"SEARCH",
"INSERT",
"UPSERT",
"UPDATE",
"DELETE",
"SET_TTL",
"ALTER_TABLE",
"CONFIG_TABLE",
"CONFIG_INDEX",
"BUILD_INDEX",
"CDC_ADMIN",
"PARTITION",
"BULKLOAD",
"ALIAS"
]
}
]
}
vectordb-cli >
回收角色的权限
描述
回收指定角色的指定的一个或多个权限元组(Privilege Tuple)。支持同时回收具体的权限和权限组(Privilege Group)。
命令
revoke role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来回收角色的权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
vectordb-cli > revoke role privilege
input revoke role privilage args, end with ';'
...
... {
... "role": "writable",
... "privilegeTuples": [
... {
... "database": "testdb",
... "table": "book",
... "privileges": ["TABLE_READWRITE"]
... }
... ]
... }
... ;
revoke role 'writable' privileges success
vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 revokeRolePrivileges.json 中的内容与上面例子中的 json 一致。
vectordb-cli > revoke role privilege -f ./example/role/revokeRolePrivileges.json
revoke role 'writable' privileges success
vectordb-cli >
检查角色当前的权限
vectordb-cli > show role privilege -r writable
{
"privilegeTuples": [
{
"database": "*",
"table": "*",
"privileges": [
"QUERY",
"SELECT",
"SEARCH"
]
},
{
"database": "testdb",
"table": "book",
"privileges": [
"CREATE_TABLE",
"DROP_TABLE",
"SHOW_TABLE",
"SET_TTL",
"ALTER_TABLE",
"CONFIG_TABLE",
"CONFIG_INDEX",
"BUILD_INDEX",
"CDC_ADMIN",
"PARTITION",
"BULKLOAD",
"ALIAS"
]
}
]
}
vectordb-cli >
根据权限筛选角色
描述
根据指定的一个或多个权限元组(Privilege Tuple)来筛选同时满足这些权限要求的角色。若不指定任何权限,则等价于列出所有角色。
命令
select role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来筛选角色,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
vectordb-cli > select role
input select role args, end with ';'
...
... {
... "privilegeTuples": [
... {
... "database": "testdb",
... "table": "book",
... "privileges": ["TABLE_CONTROL"]
... }
... ]
... }
... ;
+-------------+
| role |
+=============+
| ADMIN |
+-------------+
| writable |
+-------------+
vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 selectRole.json 中的内容与上面例子中的 json 一致。
vectordb-cli > select role -f ./example/role/selectRole.json
+-------------+
| role |
+=============+
| ADMIN |
+-------------+
| writable |
+-------------+
vectordb-cli >
User 操作
创建用户
描述
创建一个新的用户
命令
create user
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例1,创建用户成功
vectordb-cli > create user -u user1
Enter password for 'user1' :
Confirm password for 'user1':
create user 'user1' success
vectordb-cli >
示例2,错误示范
- 两次输入密码不一致,需要重试
- 空密码,需要重试
- 密码过于简单,创建失败
vectordb-cli > create user -u user2
Enter password for 'user2' :
Confirm password for 'user2':
Error: Passwords do not match. Please try again.
Enter password for 'user2' :
Confirm password for 'user2':
Error: Empty password. Please try again.
Enter password for 'user2' :
Confirm password for 'user2':
create user 'user2' failed, [Code: 2; Message: Invalid Parameter: parameter 'password' illegal; RequestId: 1a53f38f-af22-49a3-ac97-7b3618d4586b]
vectordb-cli >
删除用户
描述
删除指定的用户
命令
drop user
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > drop user -u user1
Drop user user1 ? (y/N) y
drop user 'user1' success
vectordb-cli >
修改用户密码
描述
修改指定用户的密码。密码修改规则如下:
- 每个用户可以修改自身的密码,需要验证旧密码,旧密码可以从Authrization头获得。
- 若root用户具备PASSWORD权限,那么root用户可以直接修改其它非root用户的密码,无需验证指定用户的旧密码(相当于直接重置非root用户的密码)。 故,在请求体中,始终无需指定目标用户的旧密码。
- 如果用户修改了自身的密码,需要重新登录 VectorDB-cli。
命令
change user password
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例1,修改密码成功
vectordb-cli > change user password -u user1
Enter password for 'user1' :
Confirm password for 'user1':
change user 'user1' password success
vectordb-cli >
示例2,修改自身密码成功,需要重新登录
vectordb-cli > change user password -u user1
Enter password for 'user1' :
Confirm password for 'user1':
change user 'user1' password success
Please restart vectordb-cli with new password for 'user1'
[bin]$
示例3,错误示范
- 两次输入密码不一致,需要重试
- 空密码,需要重试
- 密码过于简单,修改失败
vectordb-cli > change user password -u user1
Enter password for 'user1' :
Confirm password for 'user1':
Error: Passwords do not match. Please try again.
Enter password for 'user1' :
Confirm password for 'user1':
Error: Empty password. Please try again.
Enter password for 'user1' :
Confirm password for 'user1':
change user 'user1' password failed, [Code: 2; Message: Invalid Parameter: parameter 'newPassword' illegal; RequestId: 4e49a346-ee4b-46a6-81db-5734585caf79]
vectordb-cli >
授权用户以角色
描述
将指定的的一个或多个角色授权给指定的用户,完成授权之后,该用户自动获得这些角色具备的所有权限
命令
grant user role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-r | --role | 是 | 角色名列表 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > grant user role -u user1 -r writable -r readable
grant user 'user1' roles success
vectordb-cli >
回收用户的角色
描述
回收指定用户的指定的一个或多个角色,完成回收之后,该用户不再具备由这些角色提供的权限。需要注意的是,用户可能具备独立权限
命令
revoke user role
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-r | --role | 是 | 角色名列表 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > revoke user role -u user1 -r readable
revoke user 'user1' roles success
vectordb-cli >
授权用户以权限
描述
将指定的一个或多个权限元组(Privilege Tuple)授权给指定的用户。支持同时授权具体的权限和权限组(Privilege Group)。
命令
grant user privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来授权用户以权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
vectordb-cli > grant user privilege
input grant user privilage args, end with ';'
...
... {
... "username": "user1",
... "privilegeTuples": [
... {
... "database": "*",
... "table": "*",
... "privileges": ["QUERY", "SELECT", "SEARCH"]
... },
... {
... "database": "testdb",
... "table": "book",
... "privileges": ["TABLE_CONTROL", "TABLE_READWRITE"]
... }
... ]
... }
... ;
grant user 'user1' privileges success
vectordb-cli >
vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 grantUserPrivileges.json 中的内容与上面例子中的 json 一致。
vectordb-cli >
vectordb-cli > grant user privilege -f ./example/user/grantUserPrivileges.json
grant user 'user1' privileges success
vectordb-cli >
回收用户的权限
描述
回收指定用户的指定的一个或多个权限元组(Privilege Tuple)。支持同时回收具体的权限和权限组(Privilege Group)
命令
revoke role privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来回收用户的权限,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
vectordb-cli > revoke user privilege
input revoke user privilage args, end with ';'
...
... {
... "username": "user1",
... "privilegeTuples": [
... {
... "database": "testdb",
... "table": "book",
... "privileges": ["TABLE_READWRITE"]
... }
... ]
... }
... ;
revoke user 'user1' privileges success
vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 revokeUserPrivileges.json 中的内容与上面例子中的 json 一致。
vectordb-cli > revoke user privilege -f ./example/user/revokeUserPrivileges.json
revoke user 'user1' privileges success
vectordb-cli >
展示用户的权限
描述
展示指定用户的所有权限,以及角色
命令
show user privilege
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-u | --user | 是 | 用户名 |
-h | --help | 否 | 查看帮助信息 |
示例
vectordb-cli > show user privilege -u user1
{
"roles": [
{
"role": "readable"
},
{
"role": "writable",
"privilegeTuples": [
{
"database": "*",
"table": "*",
"privileges": [
"QUERY",
"SELECT",
"SEARCH"
]
},
{
"database": "testdb",
"table": "book",
"privileges": [
"CREATE_TABLE",
"DROP_TABLE",
"SHOW_TABLE",
"SET_TTL",
"ALTER_TABLE",
"CONFIG_TABLE",
"CONFIG_INDEX",
"BUILD_INDEX",
"CDC_ADMIN",
"PARTITION",
"BULKLOAD",
"ALIAS"
]
}
]
}
],
"privilegeTuples": [
{
"database": "*",
"table": "*",
"privileges": [
"USAGE"
]
}
]
}
vectordb-cli >
根据权限筛选用户
描述
根据指定的一个或多个权限元组(Privilege Tuple)和/或一个或多个角色来筛选同时满足这些权限要求的用户。权限元组和角色都是可选的,若不指定任何权限和任何角色,则等价于列出所有用户。
命令
select user
参数
选项 | 全名 | 是否必传 | 说明 |
---|---|---|---|
-f | --file | 否 | 指定 json 文件来输入参数,需要的 json 详见 openAPI |
-h | --help | 否 | 查看帮助信息 |
该命令需要输入一个 json 作为参数来筛选用户,有两种传参方式:
- 控制台输入json并使用';'结尾
- 通过读取指定json文件来输入参数 示例 1,控制台输入 json 参数
vectordb-cli > select user
input select user args, end with ';'
...
... {
... "roles": ["writable"],
... "privilegeTuples": [
... {
... "database": "testdb",
... "table": "book",
... "privileges": ["TABLE_CONTROL"]
... }
... ]
... }
... ;
+----------+
| user |
+==========+
| user1 |
+----------+
vectordb-cli >
示例 2,通过指定 json 文件来输入参数
下面 selectUser.json 中的内容与上面例子中的 json 一致。
vectordb-cli > select user -f ./example/user/selectUser.json
+----------+
| user |
+==========+
| user1 |
+----------+
vectordb-cli >