This article will teach you how to alter an existing role to modify the various properties such as passwords and privileges.
Let us dive in!
The following snippet shows the syntax of the create role in Cassandra:
[WITH SUPERUSER = true | false
| LOGIN = true | false
| PASSWORD = 'password'
| OPTIONS = option_map]
The following are the parameters in the given syntax:
- Role_name – This specifies the name that is used to identify a given role. Keep in mind that Cassandra will not letter case unless the name is enclosed in quotation marks.
- SUPERUSER – Setting the SUPERUSER value to true automatically grants AUTHORIZE, GRANT, and DROP on all roles. This allows the superusers to manage the other roles in the database.
- LOGIN – If set to true, the created role is treated as a standard account, allowing that username to log in with a username and password. By default, this value is set to false.
- PASSWORD – It specifies the password that the role will use to log in. Pair this value with LOGIN = true. Otherwise, skip.
- OPTIONS – Specifies the options for configured authentication plugins.
Create a User Account
The following example shows how to create a login user using the CREATE ROLE command:
... WITH PASSWORD = 'password'
... AND LOGIN = true;
Setting the PASSWORD and LOGIN = true allows you to create a standard user. You can then login into the server with the created user as:
The command prompts you to enter a password for the specified username. Once authenticated, the prompt should reflect the logged-in user as follows:
Cassandra Alter User Command
The following snippet illustrates the syntax of the Cassandra ALTER USER command:
WITH PASSWORD 'password'
[SUPERUSER | NOSUPERUSER]
For example, to change the password of the Linuxhint user that was created in the previous example, we can run the following command:
The command then modifies the account and set the new password.
To allow the user to contain the superuser privileges, we can run the following command:
Conclusion
In this article, you learned how to use the CREATE ROLE command to create a login user. You also discovered how to alter the various properties of an existing user such as setting a new password and assigning the superuser privileges.
Happy coding!