| 1 |
create user foo@localhost; |
| 2 |
grant create user on *.* to foo@localhost; |
| 3 |
create role role1; |
| 4 |
create role role2 with admin current_user; |
| 5 |
create role role3 with admin current_role; |
| 6 |
ERROR 0L000: Invalid definer |
| 7 |
create role role3 with admin role1; |
| 8 |
create role role4 with admin root@localhost; |
| 9 |
connect c1, localhost, foo,,; |
| 10 |
create role role5 with admin root@localhost; |
| 11 |
ERROR 42000: Access denied; you need (at least one of) the SET USER privilege(s) for this operation |
| 12 |
create role role5 with admin role3; |
| 13 |
ERROR 42000: Access denied; you need (at least one of) the SET USER privilege(s) for this operation |
| 14 |
create role role5 with admin foo@localhost; |
| 15 |
connection default; |
| 16 |
call mtr.add_suppression("Invalid roles_mapping table entry user:'foo@bar', rolename:'role6'"); |
| 17 |
create role role6 with admin foo@bar; |
| 18 |
Warnings: |
| 19 |
Note 1449 The user specified as a definer ('foo'@'bar') does not exist |
| 20 |
create user bar with admin current_user; |
| 21 |
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'admin current_user' at line 1 |
| 22 |
grant role1 to foo@localhost with admin option; |
| 23 |
grant role2 to foo@localhost; |
| 24 |
grant role2 to role1; |
| 25 |
grant role4 to role3 with admin option; |
| 26 |
grant select on *.* to foo@localhost with admin option; |
| 27 |
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'admin option' at line 1 |
| 28 |
show grants for foo@localhost; |
| 29 |
Grants for foo@localhost |
| 30 |
GRANT CREATE USER ON *.* TO `foo`@`localhost` |
| 31 |
GRANT `role1` TO `foo`@`localhost` WITH ADMIN OPTION |
| 32 |
GRANT `role2` TO `foo`@`localhost` |
| 33 |
GRANT `role5` TO `foo`@`localhost` WITH ADMIN OPTION |
| 34 |
show grants for role1; |
| 35 |
Grants for role1 |
| 36 |
GRANT USAGE ON *.* TO `role1` |
| 37 |
GRANT USAGE ON *.* TO `role2` |
| 38 |
GRANT USAGE ON *.* TO `role3` |
| 39 |
GRANT USAGE ON *.* TO `role4` |
| 40 |
GRANT `role2` TO `role1` |
| 41 |
GRANT `role3` TO `role1` WITH ADMIN OPTION |
| 42 |
GRANT `role4` TO `role3` WITH ADMIN OPTION |
| 43 |
show grants for role4; |
| 44 |
Grants for role4 |
| 45 |
GRANT USAGE ON *.* TO `role4` |
| 46 |
select * from mysql.roles_mapping; |
| 47 |
Host User Role Admin_option |
| 48 |
role1 role2 N |
| 49 |
role1 role3 Y |
| 50 |
role3 role4 Y |
| 51 |
bar foo role6 Y |
| 52 |
localhost foo role1 Y |
| 53 |
localhost foo role2 N |
| 54 |
localhost foo role5 Y |
| 55 |
localhost root role1 Y |
| 56 |
localhost root role2 Y |
| 57 |
localhost root role4 Y |
| 58 |
flush privileges; |
| 59 |
show grants for foo@localhost; |
| 60 |
Grants for foo@localhost |
| 61 |
GRANT CREATE USER ON *.* TO `foo`@`localhost` |
| 62 |
GRANT `role1` TO `foo`@`localhost` WITH ADMIN OPTION |
| 63 |
GRANT `role2` TO `foo`@`localhost` |
| 64 |
GRANT `role5` TO `foo`@`localhost` WITH ADMIN OPTION |
| 65 |
show grants for role1; |
| 66 |
Grants for role1 |
| 67 |
GRANT USAGE ON *.* TO `role1` |
| 68 |
GRANT USAGE ON *.* TO `role2` |
| 69 |
GRANT USAGE ON *.* TO `role3` |
| 70 |
GRANT USAGE ON *.* TO `role4` |
| 71 |
GRANT `role2` TO `role1` |
| 72 |
GRANT `role3` TO `role1` WITH ADMIN OPTION |
| 73 |
GRANT `role4` TO `role3` WITH ADMIN OPTION |
| 74 |
show grants for role4; |
| 75 |
Grants for role4 |
| 76 |
GRANT USAGE ON *.* TO `role4` |
| 77 |
select * from information_schema.applicable_roles; |
| 78 |
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT |
| 79 |
role1 role2 NO NULL |
| 80 |
role1 role3 YES NULL |
| 81 |
role3 role4 YES NULL |
| 82 |
root@localhost role1 YES NO |
| 83 |
root@localhost role2 YES NO |
| 84 |
root@localhost role4 YES NO |
| 85 |
grant role2 to role1 with admin option; |
| 86 |
revoke role1 from foo@localhost; |
| 87 |
revoke admin option for role4 from role3; |
| 88 |
revoke admin option for role2 from foo@localhost; |
| 89 |
revoke admin option for role1 from root@localhost; |
| 90 |
show grants for foo@localhost; |
| 91 |
Grants for foo@localhost |
| 92 |
GRANT CREATE USER ON *.* TO `foo`@`localhost` |
| 93 |
GRANT `role2` TO `foo`@`localhost` |
| 94 |
GRANT `role5` TO `foo`@`localhost` WITH ADMIN OPTION |
| 95 |
show grants for role1; |
| 96 |
Grants for role1 |
| 97 |
GRANT USAGE ON *.* TO `role1` |
| 98 |
GRANT USAGE ON *.* TO `role2` |
| 99 |
GRANT USAGE ON *.* TO `role3` |
| 100 |
GRANT USAGE ON *.* TO `role4` |
| 101 |
GRANT `role2` TO `role1` WITH ADMIN OPTION |
| 102 |
GRANT `role3` TO `role1` WITH ADMIN OPTION |
| 103 |
GRANT `role4` TO `role3` |
| 104 |
show grants for role4; |
| 105 |
Grants for role4 |
| 106 |
GRANT USAGE ON *.* TO `role4` |
| 107 |
select * from mysql.roles_mapping; |
| 108 |
Host User Role Admin_option |
| 109 |
role1 role2 Y |
| 110 |
role1 role3 Y |
| 111 |
role3 role4 N |
| 112 |
bar foo role6 Y |
| 113 |
localhost foo role2 N |
| 114 |
localhost foo role5 Y |
| 115 |
localhost root role1 N |
| 116 |
localhost root role2 Y |
| 117 |
localhost root role4 Y |
| 118 |
flush privileges; |
| 119 |
show grants for foo@localhost; |
| 120 |
Grants for foo@localhost |
| 121 |
GRANT CREATE USER ON *.* TO `foo`@`localhost` |
| 122 |
GRANT `role2` TO `foo`@`localhost` |
| 123 |
GRANT `role5` TO `foo`@`localhost` WITH ADMIN OPTION |
| 124 |
show grants for role1; |
| 125 |
Grants for role1 |
| 126 |
GRANT USAGE ON *.* TO `role1` |
| 127 |
GRANT USAGE ON *.* TO `role2` |
| 128 |
GRANT USAGE ON *.* TO `role3` |
| 129 |
GRANT USAGE ON *.* TO `role4` |
| 130 |
GRANT `role2` TO `role1` WITH ADMIN OPTION |
| 131 |
GRANT `role3` TO `role1` WITH ADMIN OPTION |
| 132 |
GRANT `role4` TO `role3` |
| 133 |
show grants for role4; |
| 134 |
Grants for role4 |
| 135 |
GRANT USAGE ON *.* TO `role4` |
| 136 |
select * from information_schema.applicable_roles; |
| 137 |
GRANTEE ROLE_NAME IS_GRANTABLE IS_DEFAULT |
| 138 |
role1 role2 YES NULL |
| 139 |
role1 role3 YES NULL |
| 140 |
role3 role4 NO NULL |
| 141 |
root@localhost role1 NO NO |
| 142 |
root@localhost role2 YES NO |
| 143 |
root@localhost role4 YES NO |
| 144 |
grant role1 to role4; |
| 145 |
ERROR 28000: Access denied for user 'root'@'localhost' |
| 146 |
grant role1 to role4 with admin option; |
| 147 |
ERROR 28000: Access denied for user 'root'@'localhost' |
| 148 |
grant role3 to role2; |
| 149 |
revoke role3 from role2; |
| 150 |
grant role4 to role2 with admin option; |
| 151 |
revoke role2 from current_user; |
| 152 |
revoke role4 from current_user; |
| 153 |
grant role4 to current_user; |
| 154 |
drop role role1, role2, role3, role4, role5, role6; |
| 155 |
drop user foo@localhost; |