Database Reference
In-Depth Information
Now Max and Ulf can assume the role of
admin_import_role
when they need it. Max, for
instance, would enter the following while he's logged into MariaDB to do this:
SET ROLE '
admin_import_role
';
LOAD DATA INFILE
...
SET ROLE NONE;
As you can see here, Max set his role to
admin_import_role
and then executed the
LOAD
DATA INFILE
statement — I removed the details of that SQL statement and any others
he might execute so that we can focus just on the user role. Then Max set his role to
NONE
to unassume the role.
NOTE
One drawback with roles is that they may be used only for the current session. This makes it difficult to
use with an external utilitysuch as
mysqldump
. If you run the
mysql
client from the command line to set
the role for your user account and then exit
mysql
or open a different terminal to execute the
mysqldump
,
the dump would be in a new client session and wouldn't have the assumed role. So you wouldn't have
the privileges you need.
User roles work well and are much easier than creating many user accounts and setting
passwords and privileges for each. They're ideal for granting someone a role temporarily.
They make the management of user accounts and privileges easier for you as an adminis-
trator. For users, they will need to enter only one username and password for all of their
activities. They will need only to assume a role when necessary. Of course, you will have
to rely on each user to assume the role only when necessary, and to reset therole to
NONE
afterward.