This topic describes how to create a standard account for an ApsaraDB for ClickHouse cluster by running SQL statements.

Prerequisites

  • The cluster for which you want to create a standard account is an ApsaraDB for ClickHouse cluster.
  • Your database account is a privileged account.

Limits

A maximum of 500 standard accounts can be created for a cluster.

Syntax

CREATE USER [IF NOT EXISTS] name1 [, name2, ...] [ON CLUSTER default]
    [NOT IDENTIFIED | IDENTIFIED {[WITH {auth_type}] BY {'password'}}]

Parameters

  • ON CLUSTER default: specifies that an account is created on each node. Set the value to ON CLUSTER default.
  • NOT IDENTIFIED: specifies that no password is configured for the account. You can replace NOT IDENTIFIED with IDENTIFIED WITH no_password.
  • IDENTIFIED BY 'password': specifies that a password is configured for the account and the password is encrypted by using SHA256 encryption. You can replace IDENTIFIED BY 'password' with IDENTIFIED WITH sha256_password BY 'password'.
  • auth_type: the encryption method for the password.
    • no_password: specifies that no password is configured for the account. You can log on to the cluster by using the account without a password.
    • plaintext_password: specifies that the password is in plain text.
    • sha256_password: specifies that the password is encrypted by using SHA256 encryption.

Example

  • Create an account named account1 and configure the password Account1 for the account. The password is in plain text.
    CREATE USER IF NOT EXISTS 'account1' ON CLUSTER default IDENTIFIED WITH plaintext_password BY 'Account1';
  • Create an account named account2 and configure the password Account2 for the account. The password is encrypted by using SHA256 encryption.
    • Create the account by using the IDENTIFIED BY 'password' parameter.
      CREATE USER IF NOT EXISTS 'account2' ON CLUSTER default IDENTIFIED BY 'Account2';
    • Create the account by using the IDENTIFIED WITH sha256_password BY 'password' parameter.

      CREATE USER IF NOT EXISTS 'account2' ON CLUSTER default IDENTIFIED WITH sha256_password BY 'Account2';
  • Create an account named account3 without configuring a password for the account.
    • Create the account by using the NOT IDENTIFIED parameter.
      CREATE USER IF NOT EXISTS 'account3' ON CLUSTER default NOT IDENTIFIED;
    • Create the account by using the IDENTIFIED WITH no_password parameter.
      CREATE USER IF NOT EXISTS 'account3' ON CLUSTER default IDENTIFIED WITH no_password;
  • Create two accounts named account4 and account5 at the same time and configure the password Account for the accounts. The password is encrypted by using SHA256 encryption.
    CREATE USER IF NOT EXISTS 'account4', 'account5' ON CLUSTER default IDENTIFIED BY 'Account';