init-connet设置
注:该参数对超级用户不生效
-- 创建测试库
mysql> create database test;
Query OK, 1 row affected (0.00 sec)
mysql> use test;
Database changed
-- 创建审计记录表
mysql> CREATE TABLE `conn_log` (
-> `conn_id` int(11) DEFAULT NULL,
-> `conn_time` datetime DEFAULT NULL,
-> `user_name` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
-> `cur_user_name` varchar(128) CHARACTER SET utf8 DEFAULT NULL,
-> `ip` varchar(15) CHARACTER SET utf8 DEFAULT NULL,
-> KEY `conn_time` (`conn_time`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ;
Query OK, 0 rows affected (0.01 sec)
-- 设置审计内容
mysql> set global init_connect="set @user=user(),@cur_user=current_user();insert into test.conn_log values(con