📄 grant_cache.result
字号:
drop table if exists test.t1,mysqltest.t1,mysqltest.t2;drop database if exists mysqltest;set GLOBAL query_cache_size=1355776;reset query cache;flush status;show grants for current_user;Grants for root@localhostGRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTIONshow grants;Grants for root@localhostGRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTIONcreate database if not exists mysqltest;create table mysqltest.t1 (a int,b int,c int);create table mysqltest.t2 (a int,b int,c int);insert into mysqltest.t1 values (1,1,1),(2,2,2);insert into mysqltest.t2 values (3,3,3);create table test.t1 (a char (10));insert into test.t1 values ("test.t1");select * from t1;atest.t1select * from t1;a b c1 1 12 2 2select a from t1;a12select c from t1;c12select * from t2;a b c3 3 3select * from mysqltest.t1,test.t1;a b c a1 1 1 test.t12 2 2 test.t1show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits%";Variable_name ValueQcache_hits 0grant SELECT on mysqltest.* to mysqltest_1@localhost;grant SELECT on mysqltest.t1 to mysqltest_2@localhost;grant SELECT on test.t1 to mysqltest_2@localhost;grant SELECT(a) on mysqltest.t1 to mysqltest_3@localhost;show grants for current_user();Grants for mysqltest_1@localhostGRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 0show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 5select "user1";user1user1show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 0show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 9select * from t1;a b c1 1 12 2 2show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 1show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 12select a from t1 ;a12show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 2show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 15select c from t1;c12show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 3show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 18show grants for current_user();Grants for @localhostGRANT USAGE ON *.* TO ''@'localhost'select "user2";user2user2select * from t1;a b c1 1 12 2 2select a from t1;a12select c from t1;c12select * from mysqltest.t1,test.t1;a b c a1 1 1 test.t12 2 2 test.t1select * from t2;ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 't2'show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 7show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 22select "user3";user3user3select * from t1;ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'b' in table 't1'select a from t1;a12select c from t1;ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'select * from t2;ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 't2'select mysqltest.t1.c from test.t1,mysqltest.t1;ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for column 'c' in table 't1'show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 6show status like "Qcache_hits";Variable_name ValueQcache_hits 7show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 30select "user4";user4user4show grants;Grants for mysqltest_1@localhostGRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'GRANT SELECT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'select a from t1;ERROR 3D000: No database selectedselect * from mysqltest.t1,test.t1;a b c a1 1 1 test.t12 2 2 test.t1select a from mysqltest.t1;a12select a from mysqltest.t1;a12show status like "Qcache_queries_in_cache";Variable_name ValueQcache_queries_in_cache 8show status like "Qcache_hits";Variable_name ValueQcache_hits 8show status like "Qcache_not_cached";Variable_name ValueQcache_not_cached 34set names binary;delete from mysql.user where user in ("mysqltest_1","mysqltest_2","mysqltest_3");delete from mysql.db where user in ("mysqltest_1","mysqltest_2","mysqltest_3");delete from mysql.tables_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysqltest_3");flush privileges;drop table test.t1,mysqltest.t1,mysqltest.t2;drop database mysqltest;set GLOBAL query_cache_size=default;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -