| 1 |
--source include/not_embedded.inc |
| 2 |
--source include/have_pool_of_threads.inc |
| 3 |
|
| 4 |
if (!$SERVER_AUDIT_SO) { |
| 5 |
skip No SERVER_AUDIT plugin; |
| 6 |
} |
| 7 |
|
| 8 |
install plugin server_audit soname 'server_audit'; |
| 9 |
|
| 10 |
--disable_ps2_protocol |
| 11 |
show variables like 'server_audit%'; |
| 12 |
set global server_audit_file_path=null; |
| 13 |
set global server_audit_incl_users=null; |
| 14 |
set global server_audit_file_path='server_audit.log'; |
| 15 |
set global server_audit_output_type=file; |
| 16 |
set global server_audit_logging=on; |
| 17 |
--sleep 2 |
| 18 |
connect (con1,localhost,root,,mysql); |
| 19 |
connection default; |
| 20 |
disconnect con1; |
| 21 |
--sleep 2 |
| 22 |
--sleep 2 |
| 23 |
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT |
| 24 |
--error ER_ACCESS_DENIED_ERROR |
| 25 |
connect (con1,localhost,no_such_user,,mysql); |
| 26 |
connection default; |
| 27 |
--sleep 2 |
| 28 |
set global server_audit_incl_users='odin, dva, tri'; |
| 29 |
create table t1 (id int); |
| 30 |
set global server_audit_incl_users='odin, root, dva, tri'; |
| 31 |
create table t2 (id int); |
| 32 |
set global server_audit_excl_users='odin, dva, tri'; |
| 33 |
insert into t1 values (1), (2); |
| 34 |
select * from t1; |
| 35 |
set global server_audit_incl_users='odin, root, dva, tri'; |
| 36 |
insert into t2 values (1), (2); |
| 37 |
select * from t2; |
| 38 |
alter table t1 rename renamed_t1; |
| 39 |
set global server_audit_events='connect,query'; |
| 40 |
select 1, |
| 41 |
2, |
| 42 |
# comment |
| 43 |
3; |
| 44 |
insert into t2 values (1), (2); |
| 45 |
select * from t2; |
| 46 |
--disable_ps_protocol |
| 47 |
--error ER_NO_SUCH_TABLE |
| 48 |
select * from t_doesnt_exist; |
| 49 |
--enable_ps_protocol |
| 50 |
--error 1064 |
| 51 |
syntax_error_query; |
| 52 |
drop table renamed_t1, t2; |
| 53 |
show variables like 'server_audit%'; |
| 54 |
set global server_audit_mode=1; |
| 55 |
set global server_audit_events=''; |
| 56 |
create database sa_db; |
| 57 |
--sleep 2 |
| 58 |
connect (con1,localhost,root,,test); |
| 59 |
connection con1; |
| 60 |
--sleep 2 |
| 61 |
--sleep 2 |
| 62 |
create table t1 (id2 int); |
| 63 |
insert into t1 values (1), (2); |
| 64 |
select * from t1; |
| 65 |
drop table t1; |
| 66 |
use sa_db; |
| 67 |
create table sa_t1(id int); |
| 68 |
insert into sa_t1 values (1), (2); |
| 69 |
drop table sa_t1; |
| 70 |
drop database sa_db; |
| 71 |
connection default; |
| 72 |
disconnect con1; |
| 73 |
--sleep 2 |
| 74 |
--sleep 2 |
| 75 |
create database sa_db; |
| 76 |
use sa_db; |
| 77 |
CREATE USER u1 IDENTIFIED BY 'pwd-123'; |
| 78 |
GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; |
| 79 |
SET PASSWORD FOR u1 = PASSWORD('pwd 098'); |
| 80 |
CREATE USER u3 IDENTIFIED BY ''; |
| 81 |
drop user u1, u2, u3; |
| 82 |
|
| 83 |
set global server_audit_events='query_ddl'; |
| 84 |
create table t1(id int); |
| 85 |
insert into t1 values (1), (2); |
| 86 |
select * from t1; |
| 87 |
select 2; |
| 88 |
(select 2); |
| 89 |
/*! select 2*/; |
| 90 |
/*comment*/ select 2; |
| 91 |
drop table t1; |
| 92 |
set global server_audit_events='query_ddl,query_dml'; |
| 93 |
create table t1(id int); |
| 94 |
insert into t1 values (1), (2); |
| 95 |
select * from t1; |
| 96 |
select 2; |
| 97 |
drop table t1; |
| 98 |
set global server_audit_events='query_dml'; |
| 99 |
create table t1(id int); |
| 100 |
insert into t1 values (1), (2); |
| 101 |
select * from t1; |
| 102 |
select 2; |
| 103 |
(select 2); |
| 104 |
/*! select 2*/; |
| 105 |
/*comment*/ select 2; |
| 106 |
drop table t1; |
| 107 |
set global server_audit_events='query_dcl'; |
| 108 |
create table t1(id int); |
| 109 |
insert into t1 values (1), (2); |
| 110 |
select * from t1; |
| 111 |
CREATE USER u1 IDENTIFIED BY 'pwd-123'; |
| 112 |
GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321"; |
| 113 |
SET PASSWORD |
| 114 |
# comment |
| 115 |
FOR u1 = PASSWORD('pwd 098'); |
| 116 |
--error 1064 |
| 117 |
SET PASSWORD FOR u1=<secret>; |
| 118 |
CREATE USER u3 IDENTIFIED BY ''; |
| 119 |
drop user u1, u2, u3; |
| 120 |
select 2; |
| 121 |
(select 2); |
| 122 |
/*! select 2*/; |
| 123 |
/*comment*/ select 2; |
| 124 |
drop table t1; |
| 125 |
set global server_audit_events=''; |
| 126 |
|
| 127 |
set global server_audit_query_log_limit= 15; |
| 128 |
select (1), (2), (3), (4); |
| 129 |
select 'A', 'B', 'C', 'D'; |
| 130 |
set global server_audit_query_log_limit= 1024; |
| 131 |
drop database sa_db; |
| 132 |
|
| 133 |
set global server_audit_file_path='.'; |
| 134 |
--replace_regex /\.[\\\/]/HOME_DIR\// |
| 135 |
show status like 'server_audit_current_log'; |
| 136 |
set global server_audit_file_path=''; |
| 137 |
show status like 'server_audit_current_log'; |
| 138 |
set global server_audit_file_path=' '; |
| 139 |
show status like 'server_audit_current_log'; |
| 140 |
set global server_audit_file_path='nonexisting_dir/'; |
| 141 |
show status like 'server_audit_current_log'; |
| 142 |
show variables like 'server_audit%'; |
| 143 |
uninstall plugin server_audit; |
| 144 |
--enable_ps2_protocol |
| 145 |
|
| 146 |
let $MYSQLD_DATADIR= `SELECT @@datadir`; |
| 147 |
# replace the timestamp and the hostname with constant values |
| 148 |
--replace_regex /[0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\,[^,]*\,/TIME,HOSTNAME,/ /\,[1-9][0-9]*\,/,1,/ /\,[1-9][0-9]*/,ID/ |
| 149 |
cat_file $MYSQLD_DATADIR/server_audit.log; |
| 150 |
remove_file $MYSQLD_DATADIR/server_audit.log; |
| 151 |
|