How to Configure CockroachDB Create User

Published
Length
3 min read

Luis Felipe Dias

All posts

You run the cockroachdb create user step by adding a new account in the database. Then you assign specific role grants to control what that account can read or write. Most teams create shared accounts for apps and broad roles for engineers. When roles are too broad, one bad query can change or delete critical tables. Shared accounts also make it hard to see which person ran a specific query. How the cockroachdb create user process works In this distributed database, users and roles share the

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You run the cockroachdb create user step by adding a new account in the database. Then you assign specific role grants to control what that account can read or write. Most teams create shared accounts for apps and broad roles for engineers. When roles are too broad, one bad query can change or delete critical tables. Shared accounts also make it hard to see which person ran a specific query.

How the cockroachdb create user process works

In this distributed database, users and roles share the same basic account model. A user is simply a role that has permission to log in. When an admin sets up an account, they pick a unique account name. They also set up a login method like a password or client certificate. By default, a new account has very few permissions inside the cluster.

It belongs to a default public group, which allows basic login rights. To make the account useful, the admin must grant it membership in other roles. Admins can also grant direct read or write rights on specific schemas and tables. System level options control if the account can make other databases or manage roles. Teams often group permissions into job roles like reader, writer, or admin.

Then they add each new person to the right group role. This keeps permission management clean as the engineering team grows over time. When a person leaves the team, an admin revokes their role or drops the account.

Choosing between passwords and client certificates

During account setup, admins must decide how the new user will log in. Password login is simple to set up for human users and quick tests. The database stores a hash of the password in its internal system table. Still, static passwords can leak in chat logs, code repos, or local files. Client certificates offer a stronger way for apps and services to log in.

With certificates, the cluster checks a signed digital file before starting a session. Admins can also set an expiration date on an account to limit access time. Even with expiration dates, rotating passwords and certificates across many apps takes manual work. Teams often skip rotation because they fear breaking live production services.

User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What native database roles solve and what they miss

Native roles do a great job of deciding who can enter the cluster. They also block a read-only account from changing data in a production table. This setup stops unauthorized apps from touching schemas they do not own. Still, native roles only check permissions at the table or schema level. Once a user logs in, the database trusts every valid query from that session.

A developer with read access can dump a whole table of customer emails. Native grants cannot rewrite sensitive fields like phone numbers or card numbers in results. If an engineer needs write access to fix one row, they get table-wide write rights. A mistake in a query filter can update thousands of rows at once. Also, shared database roles hide the real human identity behind each SQL statement.

Audit logs show the database role name, not the team member from your directory. To control individual queries and mask data in flight, teams need deeper session controls.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits inline in the protocol beside the service as an open-source proxy, a sidecar for your database or API. On every production query an agent or human runs, hoop.dev decides whether to pass, mask, block, or escalate it for review.

Before a query runs, hoop.dev guardrails check the statement against your rules, an AI Analyzer you configure can score intent or hold risky calls for human approval, and hoop.dev data masking rewrites sensitive fields in responses in memory. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What is the difference between a user and a role in CockroachDB?

In this database, a user and a role are the same core object. The only difference is that a user has the login privilege turned on by default.

Can a new user read tables right after creation?

No, a fresh account only gets access to the default public group. An admin must grant specific read or write privileges before the user can query tables.

How do teams stop shared database accounts from hiding user identity?

Teams map individual directory logins to database sessions instead of sharing static passwords. This links every query in the log to a specific person on the team.

The query runs. The emails stay hidden.