|
| 1 | +# Roles |
| 2 | + |
| 3 | +```{note} |
| 4 | +The following roles are available starting on revision 412 |
| 5 | +``` |
| 6 | + |
| 7 | +There are several definitions of roles in Charmed MySQL: |
| 8 | +* Predefined instance-level roles |
| 9 | +* Predefined database-level roles |
| 10 | + |
| 11 | +```{seealso} |
| 12 | +[](/explanation/users) |
| 13 | +``` |
| 14 | + |
| 15 | +## MySQL roles |
| 16 | +MySQL does not provide any built-in roles for users to get permissions from. |
| 17 | + |
| 18 | +## Charmed MySQL instance-level roles |
| 19 | + |
| 20 | +Charmed MySQL introduces the following instance-level predefined roles: |
| 21 | + |
| 22 | +* `charmed_backup`: used for the `backups` user. |
| 23 | +* `charmed_stats`: used for the `monitoring` user. |
| 24 | +* `charmed_read`: used to provide data read permissions to all databases. |
| 25 | +* `charmed_dml`: used to provide data read / write permissions to all databases. |
| 26 | +* `charmed_ddl`: used to provide schema modification permissions to all databases. |
| 27 | +* `charmed_dba`: used to provide data, schema, and system configuration permissions to all databases. |
| 28 | + |
| 29 | +Currently, `charmed_backup` cannot be requested through the relation as extra user roles. |
| 30 | + |
| 31 | +```text |
| 32 | +mysql> SELECT host, user FROM mysql.user; |
| 33 | ++-----------+------------------+ |
| 34 | +| host | user | |
| 35 | ++-----------+------------------+ |
| 36 | +| ... | ... | |
| 37 | +| % | charmed_backup | |
| 38 | +| % | charmed_dba | |
| 39 | +| % | charmed_ddl | |
| 40 | +| % | charmed_dml | |
| 41 | +| % | charmed_read | |
| 42 | +| % | charmed_stats | |
| 43 | +| ... | ... | |
| 44 | ++-----------+------------------+ |
| 45 | +``` |
| 46 | + |
| 47 | +Additionally, the role `charmed_router` is available to ease the integration with [Charmed MySQL Router](https://charmhub.io/mysql-router). |
| 48 | +This role contains all the necessary permissions for a MySQL Router relation user to operate. |
| 49 | + |
| 50 | +## Charmed MySQL database-level roles |
| 51 | + |
| 52 | +Charmed MySQL also introduces database level roles, with permissions tied to each database that's created. |
| 53 | +Example for a database named `test`: |
| 54 | + |
| 55 | +```text |
| 56 | +mysql> SELECT host, user FROM mysql.user WHERE user LIKE '%_test'; |
| 57 | ++-----------+------------------+ |
| 58 | +| host | user | |
| 59 | ++-----------+------------------+ |
| 60 | +| % | charmed_dba_test | |
| 61 | ++-----------+------------------+ |
| 62 | +``` |
| 63 | + |
| 64 | +The `charmed_dba_<database>` role contains every data and schema related permission, scoped to the database it references. |
0 commit comments