查询审计配置情况
show global variables like 'log_timestamps'; show global variables like '%general%'
开启审计
打开mysql目录下的my.ini文件,在[mysqld]节下添加:
# on为开启审计功能;off为关闭审计功能 general_log = on # 审计信息存储位置 general_log_file = D:/Program Files/MySQL/MySQL Server 5.5/generalLog.log # 开启bin-log server-id=1 log-bin=D:/Program Files/MySQL/MySQL Server 5.5/bin # 设置init-connect init-connect=insert into accesslog.accesslog values(connection_id(),now(),user(),current_user())
创建用于存放连接日志的数据库和表
create database accesslog; CREATE TABLE accesslog.accesslog (`id` int(11) primary key auto_increment, `time` timestamp, `localname` varchar(30), `matchname` varchar(30))
新建用户并分配权限