MySQL 8.0 Roles and Graphml

You may already know that MySQL 8.0 is coming with a nice requested feature : ROLES

A role is a named collection of privileges. When you watch some slidedeck about MySQL 8.0 and ROLES, some times you can see a graph illustrating the ROLES and their eventual hierarchy. From the documentation, it seems those graphs are made using the ROLES_GRAPHML() function.

I tried it… and my first try is not really what I was expecting…

Input file

To create the input file I used the following command:

mysql> SELECT ROLES_GRAPHML() into outfile '/var/lib/mysql-files/test_roles.graphml';
Query OK, 1 row affected (0.19 sec)

Then I used yEd to open the file and generate a picture:

As I said, this is not really what I expected… Let see what we need to do to achieve the expected result:


This is the final result (click to enlarge):


  1. To export to a file use SELECT ROLES_GRAPHML()
  2. Open the graphml file in yEd
  3. Go to Edit –> Propert Mapper
  4. Add a new configuration using the upper left green + sign
  5. Add a new property using the right green + sign and Apply
  6. Go to tools –> Fit Label to Node
  7. Go to Layout –> Hierarchical

I hope this small procedure helps you.

In case you are looking for more information about roles, please check this presentation from @datacharmer.

And of course, thank you Kristofer Älvring for the help in finding the right settings 😉



TEL/電話+86 13764045638
QQ 47079569