惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

美团技术团队
N
Netflix TechBlog - Medium
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
J
Java Code Geeks
V
Visual Studio Blog
H
Help Net Security
Engineering at Meta
Engineering at Meta
Hugging Face - Blog
Hugging Face - Blog
Microsoft Security Blog
Microsoft Security Blog
腾讯CDC
博客园 - 【当耐特】
B
Blog
Stack Overflow Blog
Stack Overflow Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
大猫的无限游戏
大猫的无限游戏
GbyAI
GbyAI
博客园 - 司徒正美
博客园 - 叶小钗
Y
Y Combinator Blog
MyScale Blog
MyScale Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Day 19 of 100 Days of ClickHouse®: Managing Users and Rol...
Kanishga Subramani · 2026-06-16 · via DEV Community

When people first start working with ClickHouse®, their focus is usually on performance, scalability, and query optimization.

But as ClickHouse deployments grow, another challenge quickly emerges:

How do you securely manage access to your data?

Not every user should have the same level of access. Analysts may only need read permissions, ETL pipelines need write access, developers may require schema modification privileges, and administrators often need full control over the environment.

Managing these permissions individually becomes difficult as teams grow.

This is where Role-Based Access Control (RBAC) comes into play.

In this article, we'll explore how ClickHouse handles access control, how RBAC works, and how to build a scalable permission management strategy.


Why Access Control Matters

Imagine a typical analytics environment.

User Responsibility
Admin Full system administration
Analyst Query and analyze data
ETL Service Load data into tables
Developer Create and modify objects

At first, manually assigning permissions to each user might seem manageable.

However, as your organization grows:

  • New users join the team
  • Responsibilities change
  • Multiple databases are introduced
  • Compliance requirements increase

Without a structured permission model, access management becomes difficult to maintain and audit.

Even worse, overly permissive access can expose sensitive information or allow accidental changes to production systems.


Understanding ClickHouse Access Control

ClickHouse uses an access control model built around four key components:

Users

Users are accounts that connect and authenticate to ClickHouse.

Examples include:

  • Database administrators
  • Analysts
  • Developers
  • Applications
  • ETL services

A user alone does not automatically have access to any resources.


Roles

Roles are collections of permissions that can be shared across multiple users.

Examples:

CREATE ROLE analyst_role;
CREATE ROLE developer_role;
CREATE ROLE admin_role;

Instead of managing permissions user by user, you define them once within a role.


Privileges

Privileges define the actions that can be performed.

Common privileges include:

SELECT
INSERT
ALTER
CREATE
DROP
SHOW

These permissions determine what operations users are allowed to execute.


Database Objects

Privileges are applied to database resources such as:

  • Databases
  • Tables
  • Views

For example:

GRANT SELECT ON analytics.* TO analyst_role;

This allows users assigned to the role to read data from all tables within the analytics database.


What is RBAC?

Role-Based Access Control (RBAC) is a security model where permissions are assigned to roles rather than directly to users.

Instead of this:

User A → SELECT
User B → SELECT
User C → SELECT
User D → SELECT

You create a role:

Analyst Role
      ↓
SELECT Permission
      ↓
analytics.sales

Then assign the role:

User A → Analyst Role
User B → Analyst Role
User C → Analyst Role
User D → Analyst Role

Now permission management becomes centralized and significantly easier to maintain.


How RBAC Works in ClickHouse

The relationship is straightforward:

User
  ↓
Role
  ↓
Privilege
  ↓
Database Object

This layered approach provides both flexibility and security.

Instead of managing hundreds of individual permission assignments, administrators manage a smaller set of reusable roles.


Creating Users

Let's create a new user.

CREATE USER analyst
IDENTIFIED BY 'StrongPassword123';

Verify the user:

SHOW USERS;

At this stage, the user exists but cannot access any data.

This follows an important security principle:

New users start with no privileges by default.


Creating Roles

Next, create a role.

CREATE ROLE analyst_role;

View available roles:

SHOW ROLES;

Currently the role contains no permissions.


Granting Permissions

Now assign permissions to the role.

GRANT SELECT ON analytics.* TO analyst_role;

The role can now read data from the analytics database.

However, no users are using the role yet.


Assigning Roles to Users

Connect the user to the role.

GRANT analyst_role TO analyst;

The permission chain now becomes:

User: analyst
      ↓
Role: analyst_role
      ↓
Privilege: SELECT
      ↓
Database: analytics

The analyst user can now query data.


Verifying Access

Always validate permissions after configuration.

Check permissions granted to a user:

SHOW GRANTS FOR analyst;

Check permissions assigned to a role:

SHOW GRANTS FOR analyst_role;

These commands are especially useful when troubleshooting access issues or performing audits.


Managing Multiple Roles

Real-world users often perform multiple responsibilities.

For example:

A developer might need:

  • Read access
  • Schema modification privileges

Rather than creating one oversized role, create separate roles.

CREATE ROLE reporting_role;
CREATE ROLE developer_role;

Assign both:

GRANT reporting_role TO analyst;
GRANT developer_role TO analyst;

This keeps permission management modular and easier to maintain.


Revoking Permissions

Access requirements change over time.

Permissions should be removed when no longer needed.

Example:

REVOKE SELECT ON analytics.* FROM analyst_role;

Every user assigned to the role immediately loses the permission.

This centralized control is one of the biggest advantages of RBAC.


Common Access Control Patterns

Read-Only Analyst

GRANT SELECT ON analytics.* TO analyst_role;

Allows querying data without modification rights.


ETL Service Account

GRANT INSERT ON analytics.* TO etl_role;

Suitable for ingestion pipelines and automated loaders.


Database Administrator

GRANT CREATE, INSERT, ALTER, DROP
ON analytics.*
TO admin_role;

Provides broad administrative capabilities.

These permissions should be granted carefully and only when required.


Security Best Practices

RBAC is most effective when combined with good security practices.

Recommended guidelines:

Follow the Principle of Least Privilege

Grant only the permissions necessary for a user to perform their tasks.


Prefer Roles Over Direct Grants

Role-based permissions are easier to manage, audit, and scale.


Use Strong Authentication

Protect privileged accounts with strong credentials and authentication controls.


Review Access Regularly

Permissions that were appropriate six months ago may no longer be necessary today.


Remove Inactive Accounts

Unused accounts increase security risk and should be disabled or removed.


Separate Human and Application Accounts

Applications and services should have dedicated accounts with narrowly scoped permissions.


Audit Role Assignments

Regularly verify:

  • Who has access
  • What permissions they have
  • Whether those permissions are still required

Final Thoughts

ClickHouse® RBAC provides a simple yet powerful framework for managing access at scale.

Instead of assigning permissions directly to every user, administrators can define reusable roles, attach privileges to those roles, and manage access centrally.

As ClickHouse deployments grow, this approach becomes essential for:

  • Security
  • Governance
  • Compliance
  • Operational efficiency

The key takeaway is simple:

User → Role → Privilege → Database Object

Mastering this model will help you build ClickHouse environments that are not only fast and scalable but also secure and manageable.

As your organization grows, RBAC becomes one of the most important tools for maintaining control without sacrificing flexibility.

Read more... https://quantrail-data.com/managing-users-and-roles-in-clickhouse/