Requirements:
Ensure that you have the following:
- Access to a Milvus cluster, local or remote
- Python 3.10+ and above
- Pip package manager
Installing PyMilvus
Before using this function, ensure that you have the PyMilvus package installed. PyMilvus is a Python SDK that provides a convenient way to interact with the Milvus vector database.
It is an open-source library that is developed by the Milvus community and provides a high-level interface to perform the operations such as inserting, querying, and managing the vector data.
You can install it with the following command:
Once installed, you can verify the PyMilvus package availability with the following code block:
If the previous code does not return an error, it means that you have successfully installed the PyMilvus package.
PyMilvus Create_User() Function
This method creates a user. You have to specify a username and a password. The user name must be unique globally.
The method invocation is as follows:
The method parameters are as follows:
- User – It sets the name of the user to be created.
- password – It defines the password of the user to be created as a string value.
- Using – This sets the alias of the Milvus connection to be attached to.
The method has no return value.
Example Demonstration:
The following code shows how to use the create_user() method to create a username with the password in the Milvus cluster:
connections.connect()
utility.create_user(linuxhint, password)
connections.connect(user=user, password=password)
users = utility.list_usernames()
print(f"users in Milvus: {users}")
The previous code uses the create_user() function to create a new user with the “linuxhint” username and the password of password.
Finally, we use the list_usernames function to get all the users in the Milvus cluster and print them.
PyMilvus Reset_Password() Function
The reset_password() allows us to reset the specified user’s password. The method invocation is as follows:
The method requires you to specify the username, old password, and new password. The following example code demonstrates how to use the “reset password” function.
connections.connect()
utility.reset_password(linuxhint, password, _password)
The previous code resets the password of the “linuxhint” username.
Conclusion
We explored how we can use the reset_password() function to reset the password of an existing username in the Milvus server.