github.com/matrixorigin/matrixone@v1.2.0/test/distributed/cases/zz_accesscontrol/create_user.sql (about) 1 set global enable_privilege_cache = off; 2 --env prepare statement 3 drop user if exists yellowcar,test_user,user123456,123user,`1234@fff`,`1234`,`user1234.aaaa`,`123user中文`,user_role,user123456,c_user_01,c_user_02,c_user_03,customername,customer,custom,finley,jason,`neil@192.168.1.10`; 4 drop user if exists test_user,test_user0,test_user1,test_user2,user1,user2,user3,user4,user5,user6,user7,user8,user9,user10,tester1,tester2,tester001,tester002,tester003,`daisy@192.168.1.10`,daisy; 5 drop user if exists user1,tester1,tester2,jason,finley,custom,customer,customname,c_user_01,c_user_02,c_user_03; 6 drop account if exists test5555; 7 drop role if exists low_level,mid_level,high_level,u_role; 8 drop table if exists testdb.aaa; 9 create role if not exists u_role; 10 11 --1.username,auth_string字符数字中文特殊字符组合,大小写不敏感,覆盖'',"",``;去除头尾空格 12 create user yellowcar identified by 'oldmaster'; 13 select user_name,authentication_string from mo_catalog.mo_user where user_name='yellowcar'; 14 create user user123456 identified by 'TYUJI_123@126.cn' comment '这是创建用户测试aaaa11111'; 15 select user_name,authentication_string from mo_catalog.mo_user where user_name='user123456'; 16 create user 123user identified by 'eeeeee' ; 17 select user_name, authentication_string from mo_catalog.mo_user where user_name='123user'; 18 create user Test_user identified by '12345678'; 19 create user Test_User identified by '12345678'; 20 create user `1234@fff` identified by '#¥%……&' comment 'this is test@fefffff' ; 21 select user_name, authentication_string from mo_catalog.mo_user where user_name='1234@fff'; 22 create user `1234` identified by '#¥%……&' comment 'this is test@fefffff' ; 23 select user_name, authentication_string from mo_catalog.mo_user where user_name='1234'; 24 create user `user1234.aaaa` identified by '#¥%……&' comment 'this is test@fefffff' ; 25 select user_name, authentication_string from mo_catalog.mo_user where user_name='user1234.aaaa'; 26 create user `123user中文` identified by 'eee中文' ; 27 select user_name, authentication_string from mo_catalog.mo_user where user_name='123user中文'; 28 create user "test_user0" identified by '12345678'; 29 create user ` c_user_01 ` identified by ' 1111 ' ; 30 create user " c_user_02 " identified by '1111' ; 31 create user ' c_user_03 ' identified by '1111' ; 32 select user_name, authentication_string from mo_catalog.mo_user where user_name in('c_user_01','c_user_02','c_user_03'); 33 34 --2.支持一次性创建一个/多个用户都不存在,部分存在,全部存在,名字非法,if not exist 35 create user if not exists test_user1 identified by '12345678'; 36 create user test_user1 identified by '12345678'; 37 create user if not exists test_user1 identified by '12345678'; 38 create user user1 identified by '12345678',user2 identified by '12345678',user3 identified by '12345678',user4 identified by '12345678',user5 identified by '12345678',user6 identified by '12345678',user7 identified by '12345678',user8 identified by '12345678',user9 identified by '12345678',user10 identified by '12345678' default role u_role; 39 select count(*) from mo_catalog.mo_user where user_name like 'user%'; 40 create user tester1 identified by '12345678',tester2 identified by '12345678',user3 identified by '12345678',user4 identified by '12345678'; 41 select count(*) from mo_catalog.mo_user where user_name like 'tester%'; 42 create user if not exists tester1 identified by '12345678',tester2 identified by '12345678',user3 identified by '12345678',user4 identified by '12345678'; 43 select count(*) from mo_catalog.mo_user where user_name like 'tester%'; 44 create user tester001 identified by '12345678',tester002 identified by '12345678',tester:003 identified by '12345678'; 45 create user if not exists tester001 identified by '12345678',tester002 identified by '12345678',tester:003 identified by '12345678'; 46 select count(*) from mo_catalog.mo_user where user_name like 'tester00%'; 47 48 --4.user包含@hostname,表将user与hostname存入对应列 49 CREATE USER daisy@192.168.1.10 IDENTIFIED BY '123456'; 50 select user_name, user_host from mo_catalog.mo_user where user_name='daisy'; 51 CREATE USER 'neil@192.168.1.10' IDENTIFIED BY '123456'; 52 select user_name, user_host from mo_catalog.mo_user where user_name='neil'; 53 CREATE USER 'jason'@'192.168.1.10' IDENTIFIED BY '123456'; 54 select user_name, user_host from mo_catalog.mo_user where user_name='jason'; 55 create user 'finley'@'%.example.com' IDENTIFIED BY '123456'; 56 select user_name, user_host from mo_catalog.mo_user where user_name='finley'; 57 CREATE USER 'custom'@'localhost' IDENTIFIED BY '11111'; 58 select user_name, user_host from mo_catalog.mo_user where user_name='custom'; 59 CREATE USER 'customer'@'host47.example.com' IDENTIFIED BY '1111'; 60 select user_name, user_host from mo_catalog.mo_user where user_name='customer'; 61 CREATE USER 'customername'@'%' IDENTIFIED BY '1111'; 62 select user_name, user_host from mo_catalog.mo_user where user_name='customername'; 63 CREATE USER ''@'localhost' IDENTIFIED BY '1111'; 64 65 --5.异常情况:语法语义错误,username包含冒号,default role不存在,username空,密码空 66 create user if not exists user1 ,user2 ,user3 identified by '12345678'; 67 create user if not exists all identified by '111' ; 68 create user user:1 identified by '111' ; 69 create user 'user:1' identified by '111' ; 70 create user "user:1" identified by '111' ; 71 create user `user:1` identified by '111' ; 72 create user user_aaa identified by '12345678' default role aaa ; 73 create user '' identified by '111' ; 74 create user c_user_4 identified by '' ; 75 76 --6.CREATE-DROP-CREATE,CREATE-ALTER-CREATE场景 77 create user if not exists test_user2 identified by '12345678'; 78 select user_name,authentication_string from mo_catalog.mo_user where user_name='test_user2'; 79 drop user test_user2; 80 select user_name,authentication_string from mo_catalog.mo_user where user_name='test_user2'; 81 create user if not exists test_user2 identified by '12345678'; 82 select user_name,authentication_string from mo_catalog.mo_user where user_name='test_user2'; 83 --alter account test_user2 default role moadmin identified by 'apple_987' comment'alter comment 正确'; 84 85 --7.异常:创建用户赋予moadmin角色 86 create user if not exists user1 identified by '12345678' default role moadmin; 87 88 drop user if exists yellowcar,test_user,user123456,123user,`1234@fff`,`1234`,`user1234.aaaa`,`123user中文`,user_role,user123456,c_user_01,c_user_02,c_user_03,customername,customer,custom,finley,jason,`neil@192.168.1.10`; 89 drop user if exists test_user,test_user0,test_user1,test_user2,user1,user2,user3,user4,user5,user6,user7,user8,user9,user10,tester1,tester2,tester001,tester002,tester003,`daisy@192.168.1.10`,daisy; 90 drop user if exists user1,tester1,tester2,jason,finley,custom,customer,customname,c_user_01,c_user_02,c_user_03; 91 drop account if exists test5555; 92 drop role if exists low_level,mid_level,high_level,u_role; 93 drop table if exists testdb.aaa; 94 set global enable_privilege_cache = on;