mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
96 lines
4.6 KiB
Text
96 lines
4.6 KiB
Text
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;
|
|
select user, host from mysql.user where user not like 'root';
|
|
user host
|
|
test_role1
|
|
test_role2
|
|
test_user localhost
|
|
select * from mysql.roles_mapping where UserFk like 'test_user';
|
|
HostFk UserFk RoleFk
|
|
localhost test_user test_role1
|
|
select * from mysql.roles_mapping where UserFk like 'test_role1';
|
|
HostFk UserFk RoleFk
|
|
test_role1 test_role2
|
|
grant select on *.* to 'test_role2'@'';
|
|
select * from mysql.user where user like 'test_role1';
|
|
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string is_role
|
|
test_role1 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 Y
|
|
select * from mysql.user where user like 'test_role2';
|
|
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string is_role
|
|
test_role2 Y N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 Y
|
|
flush privileges;
|
|
select * from mysql.roles_mapping;
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
set role test_role1;
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
select * from mysql.roles_mapping where HostFk='';
|
|
HostFk UserFk RoleFk
|
|
test_role1 test_role2
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
set role none;
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
select * from mysql.roles_mapping;
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
set role test_role2;
|
|
ERROR HY000: The role 'test_role2' has not been granted or is invalid.
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
select * from mysql.roles_mapping;
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
set role test_role1;
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
select * from mysql.roles_mapping where HostFk='';
|
|
HostFk UserFk RoleFk
|
|
test_role1 test_role2
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
set role none;
|
|
show grants;
|
|
Grants for test_user@localhost
|
|
GRANT USAGE ON *.* TO 'test_user'@'localhost'
|
|
GRANT test_role1 TO 'test_user'@'localhost'
|
|
select * from mysql.roles_mapping;
|
|
ERROR 42000: SELECT command denied to user 'test_user'@'localhost' for table 'roles_mapping'
|
|
delete from mysql.user where user='test_role1';
|
|
delete from mysql.user where user='test_role2';
|
|
delete from mysql.roles_mapping;
|
|
flush privileges;
|
|
drop user 'test_user'@'localhost';
|