hopeless-dream

导航

init_connect参数使用

用于普通用户的登录审计

修改my.cnf文件

init_connect='insert into auditdb.access(thread_id,login_time,localname,matchname) values (connection_id(),now(),user(),current_user());'

建库建表

create database auditdb;

create table auditdb.access(

  id int not null auto_increment,

  thread_id int not null,

  login_time timestamp,

  localname varchar(50) default null,

  matchname varchar(50) default null,

  primary key (id)

) comment '审计用户登录信息';

完成对用户授权

GRANT insert on auditdb.access to 'user1'@'%'; 

 

posted on 2022-08-23 15:18  hopeless-dream  阅读(39)  评论(0编辑  收藏  举报