# Using Roles Cont'd

__*zz-BGL*__
__*zz-Jeff*__

+ Manage roles:
  + **Example 1:** Create 2 roles `r_admin` from anywhere and `r_dev` with client address restriction
  + **Example 2:** Grant role to user
  + **Example 3:** Revoke role from user
  + **Example 4:** Set the default role for user
  + **Example 5:** Remove a role

```
~!@// Example 1@!~
CREATE ROLE 'r_admin', 'r_dev'@'localhost';

~!@// Example 2@!~
GRANT 'r_admin' TO 'TEST'@'192.168.10.%';

~!@// Example 3@!~
REVOKE 'r_admin' FROM 'TEST'@'192.168.10.%';

~!@// Example 4@!~
SET DEFAULT ROLE 'r_admin' TO 'TEST'@'192.168.10.%';

~!@// Example 5@!~
DROP ROLE 'r_admin';
```

-------------------------------------------------------------
Roles are stored in the `mysql.user` table and the host name part of the role name (if omitted) defaults to `'%'`.

You can use `SHOW GRANTS` or `SHOW GRANTS FOR CURRENT_USER()` to check the current user's privileges. `SHOW GRANTS` and `SHOW GRANTS FOR CURRENT_USER()` are different in the following aspects:
-` SHOW GRANTS` shows the privilege of the enabled role for the current user.
- `SHOW GRANTS FOR CURRENT_USER()` does not show the enabled role's privilege.
