Resolve ClickHouse "Access denied" errors by granting the correct privileges, roles, or user settings.
ClickHouse raises this error when the connected user lacks the privilege needed for the requested action. The server validates privileges defined in users.xml
or SQL-based users and roles. Grant the missing privilege, switch to a role that has it, or create a user with broader rights to clear the error.
Run SHOW GRANTS FOR current_user
. The result lists all direct grants and inherited roles, showing whether SELECT
, INSERT
, or other rights are missing on ecommerce
objects like Customers
or Orders
. Use this output to craft an exact GRANT
statement instead of guessing.
GRANT privilege [, …] ON [database.]table TO user [WITH GRANT OPTION]
; or GRANT ROLE role TO user
. Privileges include SELECT
, INSERT
, ALTER
, CREATE
, and more. Separate multiple privileges with commas. Use REVOKE
to remove them and SHOW GRANTS
to confirm.
Example: GRANT SELECT ON ecommerce.Customers TO analytics_user;
lets analytics_user
read Customers
while keeping other tables protected. Narrow, table-level privileges reduce blast radius and comply with the principle of least privilege.
Grant both INSERT
and SELECT
when the statement reads from another table: GRANT INSERT, SELECT ON ecommerce.Orders TO writer_user;
Without SELECT
, INSERT … SELECT
fails even if INSERT
alone is granted.
Create roles—read_only
, writer
, admin
—and grant privileges to roles, not users. Assign default roles minimally and use WITH GRANT OPTION
only for administrators. Document every GRANT
to ease audits.
Granting on *
unknowingly covers future tables; prefer specific tables. Forgetting SYSTEM RELOAD CONFIG
after editing users.xml
leaves changes inactive; always reload or restart ClickHouse.
Yes. GRANT SELECT ON ecommerce.* TO reporting_role;
covers existing and upcoming tables. Use cautiously.
Run REVOKE SELECT ON ecommerce.Customers FROM analytics_user;
and verify with SHOW GRANTS FOR analytics_user
.
ClickHouse caches configs. Execute SYSTEM RELOAD CONFIG
or restart the server to apply new user or quota settings.
Yes—use GRANT SELECT ON ecommerce.* TO reporting_role; This covers current and newly created tables. Monitor regularly to avoid privilege creep.
Run REVOKE SELECT ON ecommerce.Customers FROM analytics_user; and confirm with SHOW GRANTS.
ClickHouse caches configs. Execute SYSTEM RELOAD CONFIG or restart the server to load new user settings.