2013-10-17 20:52:04 -07:00
|
|
|
create user 'test_user'@'localhost';
|
|
|
|
create user 'test_role1'@'';
|
|
|
|
update mysql.user set is_role='Y' where user='test_role1';
|
|
|
|
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('localhost',
|
|
|
|
'test_user',
|
|
|
|
'test_role1');
|
|
|
|
create user 'test_role2'@'';
|
|
|
|
update mysql.user set is_role='Y' where user='test_role2';
|
|
|
|
insert into mysql.roles_mapping (HostFk, UserFk, RoleFk) values ('',
|
|
|
|
'test_role1',
|
|
|
|
'test_role2');
|
|
|
|
flush privileges;
|
|
|
|
use mysql;
|
|
|
|
select * from roles_mapping;
|
|
|
|
HostFk UserFk RoleFk
|
|
|
|
test_role1 test_role2
|
2013-10-18 06:34:27 -07:00
|
|
|
localhost test_user test_role1
|
2013-10-17 20:52:04 -07:00
|
|
|
rename user 'test_user'@'localhost' to 'test_user_rm'@'newhost';
|
|
|
|
select user, host from user where user like 'test%';
|
|
|
|
user host
|
|
|
|
test_role1
|
|
|
|
test_role2
|
|
|
|
test_user_rm newhost
|
|
|
|
select * from roles_mapping;
|
|
|
|
HostFk UserFk RoleFk
|
|
|
|
test_role1 test_role2
|
2013-10-18 06:34:27 -07:00
|
|
|
newhost test_user_rm test_role1
|
2013-10-17 20:52:04 -07:00
|
|
|
rename user 'test_role2'@'' to 'test_role2_rm'@'';
|
|
|
|
select user, host from user where user like 'test%';
|
|
|
|
user host
|
|
|
|
test_role1
|
|
|
|
test_role2_rm
|
|
|
|
test_user_rm newhost
|
|
|
|
select * from roles_mapping;
|
|
|
|
HostFk UserFk RoleFk
|
|
|
|
test_role1 test_role2_rm
|
2013-10-18 06:34:27 -07:00
|
|
|
newhost test_user_rm test_role1
|
2013-10-17 20:52:04 -07:00
|
|
|
rename user 'test_role1'@'' to 'test_role1_rm'@'';
|
|
|
|
select user, host from user where user like 'test%';
|
|
|
|
user host
|
|
|
|
test_role1_rm
|
|
|
|
test_role2_rm
|
|
|
|
test_user_rm newhost
|
|
|
|
select * from roles_mapping;
|
|
|
|
HostFk UserFk RoleFk
|
|
|
|
test_role1_rm test_role2_rm
|
2013-10-18 06:34:27 -07:00
|
|
|
newhost test_user_rm test_role1_rm
|
2013-10-17 20:52:04 -07:00
|
|
|
delete from mysql.roles_mapping;
|
|
|
|
delete from mysql.user where user like 'test%';
|
|
|
|
flush privileges;
|