Why is the error message “no permission” still reported even after the required role has been assigned to a user?
This error may happen if the role is not activated. You can runselect current_role(); to query the roles that have been activated for the user in the current session. If the required role is not activated, run SET ROLE to activate this role and perform operations using this role.
If you want roles to be automatically activated upon login, the user_admin role can run SET DEFAULT ROLE or ALTER USER DEFAULT ROLE to set a default role for each user. After the default role is set, it will be automatically activated when the user logs in.
If you want all the assigned roles of all users to be automatically activated upon login, you can run the following command. This operation requires the OPERATE permission at the System level.
- Common users can set the
read_onlyrole that has only the SELECT privilege as the default role, while avoiding setting roles with privileges like ALTER, DROP, and INSERT as default roles. - Administrators can set the
db_adminrole as the default role, while avoiding setting thenode_adminrole, which has the privilege to add and drop nodes, as the default role.
I have granted a user the privilege on all tables in a database (GRANT ALL ON ALL TABLES IN DATABASE <db_name> TO USER <user_identity>;), but the user still cannot create tables in the database. Why?
Creating tables within a database requires the database-level CREATE TABLE privilege. You need to grant the privilege to the user.
I have granted a user all the privileges on a database using GRANT ALL ON DATABASE <db_name> TO USER <user_identity>;, but nothing is returned when the user runs SHOW TABLES; in this database. Why?
SHOW TABLES; returns only tables on which the user has any privilege. If the user has no privilege on a table, this table will not be returned. You can grant any privilege on all tables in this database (using SELECT for example) to the user:
GRANT select_priv ON db.* TO <user_identity>; used in versions earlier than v3.0.
What privileges are required to access the database Web Console http://<fe_ip>:<fe_http_port>?
The user must have the db_admin and user_admin roles.
How did the privilege retention mechanism change before and after StarRocks v3.0?
Before v3.0, after a user is granted privileges on a table, the privileges would still remain even if the table was dropped and recreated. Starting from v3.0, privileges will no longer be retained after a table is dropped and recreated.How to query users and granted privileges in the database?
You can obtain the full user list via querying the system viewsys.grants_to_users or executing SHOW USERS, and then query each user individually using SHOW GRANTS FOR <user_identity>.
What is the impact on FE resources when querying system views on privilege metadata of large numbers of users and tables?
When the number of users or tables is very large, queries on system viewssys.grants_to_users, sys.grants_to_roles, and sys.role_edges may take a long time. These views are computed in real time, consuming a proportion of FE resources. Therefore, it is not recommended to run such operations frequently at large scale.