'How to create / login to a user in CockroachDB

I have created a local cockroachDB using:

cockroach sql --insecure

and when I am trying to create a user using:

create user 'name' with password 'password';

I get a error:

ERROR: setting or updating a password is not supported in insecure mode

Anyone know a workaround for this or how I can login to the admin user that already exists.

I managed to solve my issue by just using the root user instead but I would still like to know a good solution or fix for this problem for anyone else having this issue in the future since I could not find any way to login to a user or anyone who had a solution for this issue.

I created a cockroachDB in DBeaver in hopes of this insecure issue would not appear but it had the same outcome.



Solution 1:[1]

As per the CockroachDB official document, Password creation is supported only in secure clusters. To create user with password in CockroachDB you need to follow below steps.

Step 1:- Create a secure cluster. You can refer this official CockroachDB document to create secure cluster.

Step 2:- Start secure cluster to run CockroachDB in secure cluster.

Step 3:- Create a user in secure cluster. You can refer this official CockroachDB document to create user with password.

I have successfully created user with password in CockroachDB with above steps.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dadasaheb Karande