SlideShare a Scribd company logo
1 of 46
Download to read offline
A quick tour of
MySQL 8.0 roles
Giuseppe Maxia
Software explorer
!1
@datacharmer
#dataopsbarcelona
Who's this guy?
About me
ā€£ Giuseppe Maxia, a.k.a. "The Data Charmer"
ā€£ Software Explorer at VMware
ā€£ Several decades development and DB
experience
ā€£ Long timer MySQL community member.
ā€£ Blog: http://datacharmer.blogspot.com
ā€£ Twitter: @datacharmer
!2
Disclaimer
ā€¢None of what I say has
anything to do with my
company.

ā€¢I also donā€™t work for Oracle.
A long coveted feature ļ¬nally arrives
Roles overview
ā€£ Available since MySQL 8.0.0
ā€£ Created like an user
ā€£ Granted like privileges
ā€£ Need to be activated (with tricks)
!4
Up until the current GA (MySQL 5.7) there were no roles
Before roles
ā€£ CREATE USER
ā€£ GRANT, GRANT, and more granular GRANT
ā€£ CREATE USER
ā€£ GRANT, GRANT again, and then GRANT
ā€£ CREATE USER
ā€£ GRANT, GRANT, GRANT, GRANT, oops!
!5
In short: a lot of work,
with many chances to make mistakes
Why bother with this new feature?
Advantages of roles
ā€£ Faster user administration
ā€¢ deļ¬ne a role once
ā€¢ assign it many times
ā€£ Centralised grants handling
ā€¢ grant and revoke privileges to roles
ā€¢ No need to edit all users proļ¬les
ā€£ Easy to understand grants statistics
!6
A BAD example. (1)
!7
So far, so good
A BAD example. (2)
!8
WHAT DID JUST HAPPEN ? STAY TUNED TO FIND OUT
!9
Roles
usage
1CREATE ROLE
3CREATE USER
2
GRANT
PRIVILEGES to
ROLE
4GRANT ROLE
TO USER
5SET (DEFAULT)
ROLE
Like creating a user
Create role
CREATE ROLE r_lotr_dev;
## NOTE: there is no "IDENTIFIED" clause
!10
Same as we do it with users
grant privileges to role
GRANT ALL ON lotr.* TO r_lotr_dev;
!11
This one is already known
Create user
CREATE USER aragorn IDENTIFIED BY
'lotrpwd';
!12
We grant a role in a way similar to granting a privilege
Grant role to user
GRANT r_lotr_dev TO aragorn;
## NOTE: there is not an "ON" clause
## in the GRANT statement.
!13
The role needs to be activate
Set [default] role
ALTER USER aragorn DEFAULT ROLE
r_lotr_dba;
## OR
SET DEFAULT ROLE r_lotr_dba
TO aragorn;
!14
There is more than one way to do it
Unfortunately
Some important points
!15
Grants are the total of all roles privileges
A user can be granted more roles
ā€£ User can have many roles

ā€£ The default role can be a list of roles
!16
This may cause some confusion
Roles are saved in 'user' table
ā€£ Roles are users without login (= account locked
and expired password)
!17
It is there, but you can't see it
Granting a role to a user is not enough
ā€£ When we grant a privilege, the user can use it
immediately.

ā€£ When we grant a role, we ļ¬rst need to set the
default.
!18
This may look tricky, but it is really simple
We can grant a user to a user
ā€£ Roles are users without login

ā€£ But roles with login (i.e. users) can be granted.

ā€£ Privileges are assigned regardless of the host of
the user.

GRANT root@'localhost' to someuser;
ā€£ user someuser@'%' has all privileges of root from
any host

!19
You can lose track easily here
SET ROLE anyone?
ā€£ SET ROLE role_name is a session assignment of
a role

ā€£ SET DEFAULT ROLE role_name is a permanent
assignment of a role for a user

ā€£ SET ROLE DEFAULT means assign the default
role to this user for the session.
!20
Sadly, it's up to the DBA's ingenuity
Telling roles from users
ā€£ Roles are users with expired password and locked
account.

ā€£ A good workaround is using a naming convention
to tell roles apart (e.g. "r_something")
!21
There is a feature request about this matter,
but I havenā€™t seen any progress on it.
We have two new tables in 'mysql' DB dedicated to roles
Tables for roles
ā€£ role_edges reports which roles are assigned to
which users.

ā€£ default_roles takes track of the current default
roles assigned to users.
!22
Roles in action
!23
!24
Create roles
!25
Create users and apply roles
!26
Users and roles
!27
Finding roles
empirically
!28
role_edge table
(Which roles were assigned)
!29
default_roles table
(Which roles are set as default)
!30
Who are the DBAs?
!31
Who are the developers?
!32
Roles summary
!33
Default roles summary
!34
user with default role
!35
User without default role
!36
User without default role
!37
SET ROLE is not permanent
Back to the BAD example. (2)
!38
Back to the BAD example. (3)
!39
Itā€™s a all-or-nothing option
Roles can be active by default
ā€£ Starting in 8.0.2

ā€£ You can use option activate_all_roles_on_login
ā€¢ When enabled, all roles become active by default
ā€£ And mandatory_roles

ā€¢ When set, all users will get the role(s) deļ¬ned
!40
Example with mandatory roles (1)
mysql> create schema lotr;
Query OK, 1 row affected (0.00 sec)
mysql> grant select on lotr.* to r_lotr_reader;
Query OK, 0 rows affected (0.00 sec)
mysql> set global mandatory_roles='r_lotr_reader';
Query OK, 0 rows affected (0.00 sec)
mysql> create user dummy identified by 'msandbox';
Query OK, 0 rows affected (0.00 sec)
!41
Example with mandatory roles (2)
$ mysql lotr -u dummy -p
ERROR 1044 (42000): Access denied for user 'dummy'@'%'
to database ā€˜lotr'
# ====== as root ========
mysql> set global activate_all_roles_on_login=1;
$ mysql lotr -u dummy -p
mysql> show grants;
+------------------------------------------+
| Grants for dummy@% |
+------------------------------------------+
| GRANT USAGE ON *.* TO `dummy`@`%` |
| GRANT SELECT ON `lotr`.* TO `dummy`@`%` |
| GRANT `r_lotr_reader`@`%` TO `dummy`@`%` |
+------------------------------------------+
3 rows in set (0.00 sec)
!42
Example with mandatory roles (3)
$ mysql lotr -u root -p
mysql> show grantsG
*** 1. row ***
Grants for root@localhost: GRANT SELECT, INSERT, UPDATE, DELETE,
CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER,
SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE,
REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE
ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE,
CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION
*** 2. row ***
Grants for root@localhost: GRANT
BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPL
ICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_
GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_AD
MIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION
*** 3. row ***
Grants for root@localhost: GRANT SELECT ON `lotr`.* TO
`root`@`localhost`
!43
Roles are a great feature, but they could be better
Wish list
ā€£ Missing information_schema (or sys) views
ā€¢ List of global roles
ā€¢ List of roles enabled for the current session
ā€¢ List of default roles
ā€¢ List of users for a given role
ā€£ Roles active by default
!44
Latest additions
ā€£ In 8.0.3+

ā€£ You can set the default role within CREATE
USER.
!45
Q & A
!46
@datacharmer
#dataopsbarcelona

More Related Content

What's hot

Less10 undo
Less10 undoLess10 undo
Less10 undoAmit Bhalla
Ā 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder
Ā 
Iceberg: A modern table format for big data (Strata NY 2018)
Iceberg: A modern table format for big data (Strata NY 2018)Iceberg: A modern table format for big data (Strata NY 2018)
Iceberg: A modern table format for big data (Strata NY 2018)Ryan Blue
Ā 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
Ā 
Moving from SQL Server to MongoDB
Moving from SQL Server to MongoDBMoving from SQL Server to MongoDB
Moving from SQL Server to MongoDBNick Court
Ā 
An Introduction to Kafka Cruise Control with Viktor Somogyi-Vass
An Introduction to Kafka Cruise Control with Viktor Somogyi-VassAn Introduction to Kafka Cruise Control with Viktor Somogyi-Vass
An Introduction to Kafka Cruise Control with Viktor Somogyi-VassHostedbyConfluent
Ā 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architectureAmrit Kaur
Ā 
Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingLaine Campbell
Ā 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionFrederic Descamps
Ā 
Oracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture PerformanceOracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture PerformanceEnkitec
Ā 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slidesMohamed Farouk
Ā 
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RACThe Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RACMarkus Michalewicz
Ā 
Spark Summit EU talk by Simon Whitear
Spark Summit EU talk by Simon WhitearSpark Summit EU talk by Simon Whitear
Spark Summit EU talk by Simon WhitearSpark Summit
Ā 
Oracle User Management
Oracle User ManagementOracle User Management
Oracle User ManagementArun Sharma
Ā 
MySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxMySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxNeoClova
Ā 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfSrirakshaSrinivasan2
Ā 
Oracle db architecture
Oracle db architectureOracle db architecture
Oracle db architectureSimon Huang
Ā 
Oracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONOracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONMarkus Michalewicz
Ā 

What's hot (20)

Db2 partitioning
Db2 partitioningDb2 partitioning
Db2 partitioning
Ā 
Less10 undo
Less10 undoLess10 undo
Less10 undo
Ā 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 2
Ā 
Iceberg: A modern table format for big data (Strata NY 2018)
Iceberg: A modern table format for big data (Strata NY 2018)Iceberg: A modern table format for big data (Strata NY 2018)
Iceberg: A modern table format for big data (Strata NY 2018)
Ā 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Ā 
Moving from SQL Server to MongoDB
Moving from SQL Server to MongoDBMoving from SQL Server to MongoDB
Moving from SQL Server to MongoDB
Ā 
An Introduction to Kafka Cruise Control with Viktor Somogyi-Vass
An Introduction to Kafka Cruise Control with Viktor Somogyi-VassAn Introduction to Kafka Cruise Control with Viktor Somogyi-Vass
An Introduction to Kafka Cruise Control with Viktor Somogyi-Vass
Ā 
12. oracle database architecture
12. oracle database architecture12. oracle database architecture
12. oracle database architecture
Ā 
Understanding MySQL Performance through Benchmarking
Understanding MySQL Performance through BenchmarkingUnderstanding MySQL Performance through Benchmarking
Understanding MySQL Performance through Benchmarking
Ā 
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code ExtensionMySQL Day Roma - MySQL Shell and Visual Studio Code Extension
MySQL Day Roma - MySQL Shell and Visual Studio Code Extension
Ā 
Oracle DBA
Oracle DBAOracle DBA
Oracle DBA
Ā 
Oracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture PerformanceOracle GoldenGate Architecture Performance
Oracle GoldenGate Architecture Performance
Ā 
Understanding oracle rac internals part 2 - slides
Understanding oracle rac internals   part 2 - slidesUnderstanding oracle rac internals   part 2 - slides
Understanding oracle rac internals part 2 - slides
Ā 
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RACThe Top 5 Reasons to Deploy Your Applications on Oracle RAC
The Top 5 Reasons to Deploy Your Applications on Oracle RAC
Ā 
Spark Summit EU talk by Simon Whitear
Spark Summit EU talk by Simon WhitearSpark Summit EU talk by Simon Whitear
Spark Summit EU talk by Simon Whitear
Ā 
Oracle User Management
Oracle User ManagementOracle User Management
Oracle User Management
Ā 
MySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docxMySQL_SQL_Tunning_v0.1.3.docx
MySQL_SQL_Tunning_v0.1.3.docx
Ā 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Ā 
Oracle db architecture
Oracle db architectureOracle db architecture
Oracle db architecture
Ā 
Oracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONOracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLON
Ā 

Similar to A quick tour of Mysql 8 roles

Clase 19 roles modificada
Clase 19 roles   modificadaClase 19 roles   modificada
Clase 19 roles modificadaTitiushko Jazz
Ā 
Clase 19 roles modificada
Clase 19 roles   modificadaClase 19 roles   modificada
Clase 19 roles modificadaTitiushko Jazz
Ā 
Accessing data through hibernate: what DBAs should tell to developers and vic...
Accessing data through hibernate: what DBAs should tell to developers and vic...Accessing data through hibernate: what DBAs should tell to developers and vic...
Accessing data through hibernate: what DBAs should tell to developers and vic...Marco Tusa
Ā 
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...Marco Tusa
Ā 
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksSoutheast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksDave Stokes
Ā 
Role-Based Access Control (RBAC) in Neo4j
Role-Based Access Control (RBAC) in Neo4jRole-Based Access Control (RBAC) in Neo4j
Role-Based Access Control (RBAC) in Neo4jNeo4j
Ā 
Let your DBAs get some REST(api)
Let your DBAs get some REST(api)Let your DBAs get some REST(api)
Let your DBAs get some REST(api)Ludovico Caldara
Ā 
Scaling Twitter
Scaling TwitterScaling Twitter
Scaling TwitterBlaine
Ā 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758davidblum
Ā 
Write the query for creating the users exp 11
Write the query for creating the users exp 11Write the query for creating the users exp 11
Write the query for creating the users exp 11vishal choudhary
Ā 
New and improved hacking oracle from web apps sumit sidharth
New and improved hacking oracle from web apps   sumit sidharthNew and improved hacking oracle from web apps   sumit sidharth
New and improved hacking oracle from web apps sumit sidharthowaspindia
Ā 
Forumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate AffairForumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate Affairguest06ed72
Ā 
Not so blind SQL Injection
Not so blind SQL InjectionNot so blind SQL Injection
Not so blind SQL InjectionFrancisco Ribeiro
Ā 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackDavid Copeland
Ā 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module DevelopmentSumeet Pareek
Ā 
Percona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAPercona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAJenni Snyder
Ā 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module developmentdrupalindia
Ā 

Similar to A quick tour of Mysql 8 roles (20)

Clase 19 roles modificada
Clase 19 roles   modificadaClase 19 roles   modificada
Clase 19 roles modificada
Ā 
Clase 19 roles modificada
Clase 19 roles   modificadaClase 19 roles   modificada
Clase 19 roles modificada
Ā 
Plproxy
PlproxyPlproxy
Plproxy
Ā 
Accessing data through hibernate: what DBAs should tell to developers and vic...
Accessing data through hibernate: what DBAs should tell to developers and vic...Accessing data through hibernate: what DBAs should tell to developers and vic...
Accessing data through hibernate: what DBAs should tell to developers and vic...
Ā 
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
Accessing Data Through Hibernate; What DBAs Should Tell Developers and Vice V...
Ā 
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & TricksSoutheast Linuxfest -- MySQL User Admin Tips & Tricks
Southeast Linuxfest -- MySQL User Admin Tips & Tricks
Ā 
Role-Based Access Control (RBAC) in Neo4j
Role-Based Access Control (RBAC) in Neo4jRole-Based Access Control (RBAC) in Neo4j
Role-Based Access Control (RBAC) in Neo4j
Ā 
Let your DBAs get some REST(api)
Let your DBAs get some REST(api)Let your DBAs get some REST(api)
Let your DBAs get some REST(api)
Ā 
Scaling Twitter
Scaling TwitterScaling Twitter
Scaling Twitter
Ā 
Mysql S&M
Mysql S&MMysql S&M
Mysql S&M
Ā 
Scaling Twitter 12758
Scaling Twitter 12758Scaling Twitter 12758
Scaling Twitter 12758
Ā 
Write the query for creating the users exp 11
Write the query for creating the users exp 11Write the query for creating the users exp 11
Write the query for creating the users exp 11
Ā 
New and improved hacking oracle from web apps sumit sidharth
New and improved hacking oracle from web apps   sumit sidharthNew and improved hacking oracle from web apps   sumit sidharth
New and improved hacking oracle from web apps sumit sidharth
Ā 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
Ā 
Forumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate AffairForumwarz and RJS: A Love/Hate Affair
Forumwarz and RJS: A Love/Hate Affair
Ā 
Not so blind SQL Injection
Not so blind SQL InjectionNot so blind SQL Injection
Not so blind SQL Injection
Ā 
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power StackRails, Postgres, Angular, and Bootstrap: The Power Stack
Rails, Postgres, Angular, and Bootstrap: The Power Stack
Ā 
Drupal Module Development
Drupal Module DevelopmentDrupal Module Development
Drupal Module Development
Ā 
Percona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAPercona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBA
Ā 
Advanced Module development
Advanced Module developmentAdvanced Module development
Advanced Module development
Ā 

More from Giuseppe Maxia

MySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerMySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerGiuseppe Maxia
Ā 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_bossGiuseppe Maxia
Ā 
Dbdeployer, the universal installer
Dbdeployer, the universal installerDbdeployer, the universal installer
Dbdeployer, the universal installerGiuseppe Maxia
Ā 
Test complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerTest complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerGiuseppe Maxia
Ā 
MySQL document_store
MySQL document_storeMySQL document_store
MySQL document_storeGiuseppe Maxia
Ā 
Replication skeptic
Replication skepticReplication skeptic
Replication skepticGiuseppe Maxia
Ā 
Synchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBSynchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBGiuseppe Maxia
Ā 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorGiuseppe Maxia
Ā 
MySQL in your laptop
MySQL in your laptopMySQL in your laptop
MySQL in your laptopGiuseppe Maxia
Ā 
Tungsten Replicator tutorial
Tungsten Replicator tutorialTungsten Replicator tutorial
Tungsten Replicator tutorialGiuseppe Maxia
Ā 
Preventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenPreventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenGiuseppe Maxia
Ā 
MySQL high availability power and usability
MySQL high availability power and usabilityMySQL high availability power and usability
MySQL high availability power and usabilityGiuseppe Maxia
Ā 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenGiuseppe Maxia
Ā 
State of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringState of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringGiuseppe Maxia
Ā 
Testing mysql creatively in a sandbox
Testing mysql creatively in a sandboxTesting mysql creatively in a sandbox
Testing mysql creatively in a sandboxGiuseppe Maxia
Ā 
Mysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationMysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationGiuseppe Maxia
Ā 
Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012Giuseppe Maxia
Ā 

More from Giuseppe Maxia (20)

MySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployerMySQL NDB 8.0 clusters in your laptop with dbdeployer
MySQL NDB 8.0 clusters in your laptop with dbdeployer
Ā 
Test like a_boss
Test like a_bossTest like a_boss
Test like a_boss
Ā 
Dbdeployer, the universal installer
Dbdeployer, the universal installerDbdeployer, the universal installer
Dbdeployer, the universal installer
Ā 
Test complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployerTest complex database systems in your laptop with dbdeployer
Test complex database systems in your laptop with dbdeployer
Ā 
Dbdeployer
DbdeployerDbdeployer
Dbdeployer
Ā 
Dbdeployer
DbdeployerDbdeployer
Dbdeployer
Ā 
MySQL document_store
MySQL document_storeMySQL document_store
MySQL document_store
Ā 
Replication skeptic
Replication skepticReplication skeptic
Replication skeptic
Ā 
Synchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDBSynchronise your data between MySQL and MongoDB
Synchronise your data between MySQL and MongoDB
Ā 
Juggle your data with Tungsten Replicator
Juggle your data with Tungsten ReplicatorJuggle your data with Tungsten Replicator
Juggle your data with Tungsten Replicator
Ā 
MySQL in your laptop
MySQL in your laptopMySQL in your laptop
MySQL in your laptop
Ā 
Script it
Script itScript it
Script it
Ā 
Tungsten Replicator tutorial
Tungsten Replicator tutorialTungsten Replicator tutorial
Tungsten Replicator tutorial
Ā 
Preventing multi master conflicts with tungsten
Preventing multi master conflicts with tungstenPreventing multi master conflicts with tungsten
Preventing multi master conflicts with tungsten
Ā 
MySQL high availability power and usability
MySQL high availability power and usabilityMySQL high availability power and usability
MySQL high availability power and usability
Ā 
Solving MySQL replication problems with Tungsten
Solving MySQL replication problems with TungstenSolving MySQL replication problems with Tungsten
Solving MySQL replication problems with Tungsten
Ā 
State of the art of MySQL replication and clustering
State of the art of MySQL replication and clusteringState of the art of MySQL replication and clustering
State of the art of MySQL replication and clustering
Ā 
Testing mysql creatively in a sandbox
Testing mysql creatively in a sandboxTesting mysql creatively in a sandbox
Testing mysql creatively in a sandbox
Ā 
Mysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replicationMysql 5.5 and 5.6 replication
Mysql 5.5 and 5.6 replication
Ā 
Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012Lightning talks percona live mysql_2012
Lightning talks percona live mysql_2012
Ā 

Recently uploaded

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
Ā 
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhisoniya singh
Ā 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
Ā 
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Patryk Bandurski
Ā 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
Ā 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
Ā 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
Ā 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
Ā 
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphSIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphNeo4j
Ā 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
Ā 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
Ā 
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024BookNet Canada
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
Ā 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
Ā 

Recently uploaded (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Ā 
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
Ā 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
Ā 
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Integration and Automation in Practice: CI/CD in MuleĀ Integration and Automat...
Ā 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
Ā 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Ā 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
Ā 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Ā 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Ā 
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphSIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
Ā 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
Ā 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
Ā 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Ā 
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Ā 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
Ā 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
Ā 

A quick tour of Mysql 8 roles

  • 1. A quick tour of MySQL 8.0 roles Giuseppe Maxia Software explorer !1 @datacharmer #dataopsbarcelona
  • 2. Who's this guy? About me ā€£ Giuseppe Maxia, a.k.a. "The Data Charmer" ā€£ Software Explorer at VMware ā€£ Several decades development and DB experience ā€£ Long timer MySQL community member. ā€£ Blog: http://datacharmer.blogspot.com ā€£ Twitter: @datacharmer !2
  • 3. Disclaimer ā€¢None of what I say has anything to do with my company. ā€¢I also donā€™t work for Oracle.
  • 4. A long coveted feature ļ¬nally arrives Roles overview ā€£ Available since MySQL 8.0.0 ā€£ Created like an user ā€£ Granted like privileges ā€£ Need to be activated (with tricks) !4
  • 5. Up until the current GA (MySQL 5.7) there were no roles Before roles ā€£ CREATE USER ā€£ GRANT, GRANT, and more granular GRANT ā€£ CREATE USER ā€£ GRANT, GRANT again, and then GRANT ā€£ CREATE USER ā€£ GRANT, GRANT, GRANT, GRANT, oops! !5 In short: a lot of work, with many chances to make mistakes
  • 6. Why bother with this new feature? Advantages of roles ā€£ Faster user administration ā€¢ deļ¬ne a role once ā€¢ assign it many times ā€£ Centralised grants handling ā€¢ grant and revoke privileges to roles ā€¢ No need to edit all users proļ¬les ā€£ Easy to understand grants statistics !6
  • 7. A BAD example. (1) !7 So far, so good
  • 8. A BAD example. (2) !8 WHAT DID JUST HAPPEN ? STAY TUNED TO FIND OUT
  • 9. !9 Roles usage 1CREATE ROLE 3CREATE USER 2 GRANT PRIVILEGES to ROLE 4GRANT ROLE TO USER 5SET (DEFAULT) ROLE
  • 10. Like creating a user Create role CREATE ROLE r_lotr_dev; ## NOTE: there is no "IDENTIFIED" clause !10
  • 11. Same as we do it with users grant privileges to role GRANT ALL ON lotr.* TO r_lotr_dev; !11
  • 12. This one is already known Create user CREATE USER aragorn IDENTIFIED BY 'lotrpwd'; !12
  • 13. We grant a role in a way similar to granting a privilege Grant role to user GRANT r_lotr_dev TO aragorn; ## NOTE: there is not an "ON" clause ## in the GRANT statement. !13
  • 14. The role needs to be activate Set [default] role ALTER USER aragorn DEFAULT ROLE r_lotr_dba; ## OR SET DEFAULT ROLE r_lotr_dba TO aragorn; !14 There is more than one way to do it Unfortunately
  • 16. Grants are the total of all roles privileges A user can be granted more roles ā€£ User can have many roles ā€£ The default role can be a list of roles !16
  • 17. This may cause some confusion Roles are saved in 'user' table ā€£ Roles are users without login (= account locked and expired password) !17
  • 18. It is there, but you can't see it Granting a role to a user is not enough ā€£ When we grant a privilege, the user can use it immediately. ā€£ When we grant a role, we ļ¬rst need to set the default. !18
  • 19. This may look tricky, but it is really simple We can grant a user to a user ā€£ Roles are users without login ā€£ But roles with login (i.e. users) can be granted. ā€£ Privileges are assigned regardless of the host of the user. GRANT root@'localhost' to someuser; ā€£ user someuser@'%' has all privileges of root from any host !19
  • 20. You can lose track easily here SET ROLE anyone? ā€£ SET ROLE role_name is a session assignment of a role ā€£ SET DEFAULT ROLE role_name is a permanent assignment of a role for a user ā€£ SET ROLE DEFAULT means assign the default role to this user for the session. !20
  • 21. Sadly, it's up to the DBA's ingenuity Telling roles from users ā€£ Roles are users with expired password and locked account. ā€£ A good workaround is using a naming convention to tell roles apart (e.g. "r_something") !21 There is a feature request about this matter, but I havenā€™t seen any progress on it.
  • 22. We have two new tables in 'mysql' DB dedicated to roles Tables for roles ā€£ role_edges reports which roles are assigned to which users. ā€£ default_roles takes track of the current default roles assigned to users. !22
  • 25. !25 Create users and apply roles
  • 31. !31 Who are the developers?
  • 37. !37 SET ROLE is not permanent
  • 38. Back to the BAD example. (2) !38
  • 39. Back to the BAD example. (3) !39
  • 40. Itā€™s a all-or-nothing option Roles can be active by default ā€£ Starting in 8.0.2 ā€£ You can use option activate_all_roles_on_login ā€¢ When enabled, all roles become active by default ā€£ And mandatory_roles ā€¢ When set, all users will get the role(s) deļ¬ned !40
  • 41. Example with mandatory roles (1) mysql> create schema lotr; Query OK, 1 row affected (0.00 sec) mysql> grant select on lotr.* to r_lotr_reader; Query OK, 0 rows affected (0.00 sec) mysql> set global mandatory_roles='r_lotr_reader'; Query OK, 0 rows affected (0.00 sec) mysql> create user dummy identified by 'msandbox'; Query OK, 0 rows affected (0.00 sec) !41
  • 42. Example with mandatory roles (2) $ mysql lotr -u dummy -p ERROR 1044 (42000): Access denied for user 'dummy'@'%' to database ā€˜lotr' # ====== as root ======== mysql> set global activate_all_roles_on_login=1; $ mysql lotr -u dummy -p mysql> show grants; +------------------------------------------+ | Grants for dummy@% | +------------------------------------------+ | GRANT USAGE ON *.* TO `dummy`@`%` | | GRANT SELECT ON `lotr`.* TO `dummy`@`%` | | GRANT `r_lotr_reader`@`%` TO `dummy`@`%` | +------------------------------------------+ 3 rows in set (0.00 sec) !42
  • 43. Example with mandatory roles (3) $ mysql lotr -u root -p mysql> show grantsG *** 1. row *** Grants for root@localhost: GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, RELOAD, SHUTDOWN, PROCESS, FILE, REFERENCES, INDEX, ALTER, SHOW DATABASES, SUPER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, REPLICATION SLAVE, REPLICATION CLIENT, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, CREATE USER, EVENT, TRIGGER, CREATE TABLESPACE, CREATE ROLE, DROP ROLE ON *.* TO `root`@`localhost` WITH GRANT OPTION *** 2. row *** Grants for root@localhost: GRANT BACKUP_ADMIN,BINLOG_ADMIN,CONNECTION_ADMIN,ENCRYPTION_KEY_ADMIN,GROUP_REPL ICATION_ADMIN,PERSIST_RO_VARIABLES_ADMIN,REPLICATION_SLAVE_ADMIN,RESOURCE_ GROUP_ADMIN,RESOURCE_GROUP_USER,ROLE_ADMIN,SET_USER_ID,SYSTEM_VARIABLES_AD MIN,XA_RECOVER_ADMIN ON *.* TO `root`@`localhost` WITH GRANT OPTION *** 3. row *** Grants for root@localhost: GRANT SELECT ON `lotr`.* TO `root`@`localhost` !43
  • 44. Roles are a great feature, but they could be better Wish list ā€£ Missing information_schema (or sys) views ā€¢ List of global roles ā€¢ List of roles enabled for the current session ā€¢ List of default roles ā€¢ List of users for a given role ā€£ Roles active by default !44
  • 45. Latest additions ā€£ In 8.0.3+ ā€£ You can set the default role within CREATE USER. !45