To put it simply, a role is a collection of privileges. To create a role in MySQL 8, you must have the global CREATE ROLE or CREATE USER privilege. MySQL 8 provides various privileges to attach to roles and users. Refer to https://dev.mysql.com/doc/refman/8.0/en/privileges-provided.html for more details on the available privileges.
Now, let's take an example to understand the role creation and privileges assignment. Assume we have a hr_employee table already created in the current database and we want to give access of this table to the hrdepartment role. This dilemma can be resolved by making use of the following code:
CREATE ROLE hrdepartment;
grant all on hr_employee to hrdepartment;
The above code will help us to create the hrdepartment role and grant all the necessary access to it. This topic will be covered in detailed in Chapter 11, Security.
...