Skip to main content
SET DEFAULT ROLE sets the roles that are activated by default when the user connects to the server. This command is supported from v3.0. Tip Common users can set default roles for themselves. Users with the user_admin role can set default roles for other users. Before you perform this operation, make sure that the user has already been assigned these roles. You can query the roles of a user using SHOW GRANTS.

Syntax

Parameters

role_name: the role name user_identity: the user identity

Examples

Query the roles of the current user.
Example 1: Set roles db_admin and user_admin as the default roles for the user test.
Example 2: Set all roles of the user test, including roles that will be assigned to this user as default roles.
Example 3: Clear all the default roles of the user test.