2014-07-14 01:57:10 +02:00
|
|
|
create user test_user@localhost;
|
|
|
|
create role test_role;
|
|
|
|
grant select on *.* to test_role;
|
|
|
|
grant test_role to test_user@localhost;
|
2016-03-25 17:51:22 +01:00
|
|
|
connect c1, localhost, test_user,,;
|
2014-07-14 01:57:10 +02:00
|
|
|
show grants;
|
|
|
|
Grants for test_user@localhost
|
2019-11-06 12:35:19 +01:00
|
|
|
GRANT `test_role` TO `test_user`@`localhost`
|
|
|
|
GRANT USAGE ON *.* TO `test_user`@`localhost`
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'user'
|
|
|
|
set default role test_role;
|
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'user'
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect c1;
|
|
|
|
connection default;
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
user host default_role
|
|
|
|
test_user localhost test_role
|
2016-03-25 17:51:22 +01:00
|
|
|
connect c1, localhost, test_user,,;
|
2014-07-14 01:57:10 +02:00
|
|
|
show grants;
|
|
|
|
Grants for test_user@localhost
|
2019-11-06 12:35:19 +01:00
|
|
|
GRANT `test_role` TO `test_user`@`localhost`
|
|
|
|
GRANT USAGE ON *.* TO `test_user`@`localhost`
|
|
|
|
GRANT SELECT ON *.* TO `test_role`
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
user host default_role
|
|
|
|
test_user localhost test_role
|
|
|
|
set default role NONE;
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect c1;
|
|
|
|
connection default;
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
user host default_role
|
|
|
|
test_user localhost
|
2016-03-25 17:51:22 +01:00
|
|
|
connect c1, localhost, test_user,,;
|
2014-07-14 01:57:10 +02:00
|
|
|
show grants;
|
|
|
|
Grants for test_user@localhost
|
2019-11-06 12:35:19 +01:00
|
|
|
GRANT `test_role` TO `test_user`@`localhost`
|
|
|
|
GRANT USAGE ON *.* TO `test_user`@`localhost`
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'user'
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect c1;
|
|
|
|
connection default;
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
user host default_role
|
|
|
|
test_user localhost
|
|
|
|
set default role test_role for test_user@localhost;
|
2016-03-25 17:51:22 +01:00
|
|
|
connect c1, localhost, test_user,,;
|
2014-07-14 01:57:10 +02:00
|
|
|
show grants;
|
|
|
|
Grants for test_user@localhost
|
2019-11-06 12:35:19 +01:00
|
|
|
GRANT `test_role` TO `test_user`@`localhost`
|
|
|
|
GRANT USAGE ON *.* TO `test_user`@`localhost`
|
|
|
|
GRANT SELECT ON *.* TO `test_role`
|
2014-07-14 01:57:10 +02:00
|
|
|
select user, host, default_role from mysql.user where user = 'test_user';
|
|
|
|
user host default_role
|
|
|
|
test_user localhost test_role
|
2016-03-25 17:51:22 +01:00
|
|
|
disconnect c1;
|
|
|
|
connection default;
|
2014-07-14 01:57:10 +02:00
|
|
|
drop role test_role;
|
|
|
|
drop user test_user@localhost;
|