Updated on 2024-12-24 GMT+08:00

Using User Management Commands

This section describes how to use basic syntax and SQL statements to manage users.

  1. Creating a user
    CREATE USER name IF NOT EXISTS ON CLUSTER default_cluster IDENTIFIED WITH sha256_password BY 'password';
  2. Specifying the IP address
    CREATE USER name HOST IP '127.0.0.x' IDENTIFIED WITH sha256_password BY 'password';
  3. Changing a user password
    ALTER USER name IF EXISTSON CLUSTER default_cluster IDENTIFIED WITH sha256_password BY 'password';
  4. Assigning a role to the user
    GRANT role1, role2 TO new_user ON CLUSTER default_cluster;
  5. Canceling the role assignment.
    REVOKE role1 FROM user ON CLUSTER default_cluster;
  6. Deleting a user
    DROP USER IF EXISTS 'name1'ON CLUSTER default_cluster;