DEV Community

Javier Vidal
Javier Vidal

Posted on • Edited on

10 3

How to create a read-only user in ClickHouse

In ClickHouse, a settings profile is a collection of settings grouped under the same name. By default, there is a profile readonly that allows only read queries. This is from /etc/clickhouse-server/users.xml:

<yandex>
    <!-- Profiles of settings. -->
    <profiles>
        ...
        <!-- Profile that allows only read queries. -->
        <readonly>
            <readonly>1</readonly>
        </readonly>
    </profiles>
...
Enter fullscreen mode Exit fullscreen mode

So to create a read-only user we just have to:

CREATE USER username IDENTIFIED WITH plaintext_password BY 'qwerty' SETTINGS PROFILE 'readonly'
GRANT SHOW TABLES, SELECT ON database.* TO username
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay