步骤

启用用户身份验证

在 milvus 中配置账号密码,首先需要启用用户身份验证。

在 milvus 的配置文件 milvus.yaml 中,将 common.security.authorizationEnabled 设置为 true。这样就可以启用 Milvus 服务器的用户身份验证功能。

以 docker compose 为例

...
common:
...
  security:
    authorizationEnabled: false
    # The superusers will ignore some system check processes,
    # like the old password verification when updating the credential
    superUsers: 
    defaultRootPassword: Milvus # default password for root user
    tlsMode: 0
...

连接 Milvus

启用身份验证后,连接到 milvus 需要使用用户名和密码。

默认情况下,启动 milvus 时会创建一个 root 用户。

python 连接 milvus 示例如下:

from pymilvus import MilvusClient

client = MilvusClient(
    uri='http://localhost:19530', # replace with your own Milvus server address
    # Milvus 为 root 的默认密码
    token="root:Milvus"
) 



参考文档