"MySQL" MySQL audit operation Record

Source: Internet
Author: User
Tags mysql in

Server_audit is a built-in MARIADB audit plugin that works equally well in MySQL and is used primarily to record user actions

1. Installation:

通过show variables like ‘plugin_dir‘;查看你的插件目录,我的是:/usr/lib64/mysql/plugin/????把下载好的插件server_audit.so复制到/usr/lib64/mysql/plugin/ 注意chmod+x?server_audit.so登录mysql执行插件安装命令:INSTALL PLUGIN server_audit SONAME ‘server_audit.so‘;插件安装成功后有这些全局变量:show variables like ‘%audit%‘;

2. Configuration:

进入mysql 执行:更改全局变量set global server_audit_excl_users=‘root‘;set global server_audit_events=‘QUERY_DDL,QUERY_DML‘;set global server_audit_file_path =‘/mysqllog/‘;set global server_audit_file_rotate_size=1073741824;set global server_audit_file_rotations=10;set global server_audit_file_rotate_now=ON;set global server_audit_logging=on;在my.cnf 增加#auditserver_audit_events=‘QUERY_DDL,QUERY_DML‘server_audit_logging=onserver_audit_file_path =/mysqllog/server_audit_file_rotate_size=1Gserver_audit_file_rotations=10server_audit_file_rotate_now=ONserver_audit_excl_users=root

3. Recommend closing general log

set global general_log=off;在my.cnf注释general_log_file = /mysqllog/mysql.loggeneral_log = 1

4. Parameter Description:

详细请参考:https://mariadb.com/kb/en/mariadb/server_audit-system-variables/server_audit_output_type:指定日志输出类型,可为SYSLOG或FILEserver_audit_logging:启动或关闭审计server_audit_events:指定记录事件的类型,可以用逗号分隔的多个值(connect,query,table),如果开启了查询缓存(query cache),查询直接从查询缓存返回数据,将没有table记录server_audit_file_path:如server_audit_output_type为FILE,使用该变量设置存储日志的文件,可以指定目录,默认存放在数据目录的server_audit.log文件中server_audit_file_rotate_size:限制日志文件的大小server_audit_file_rotations:指定日志文件的数量,如果为0日志将从不轮转server_audit_file_rotate_now:强制日志文件轮转server_audit_incl_users:指定哪些用户的活动将记录,connect将不受此变量影响,该变量比server_audit_excl_users优先级高server_audit_syslog_facility:默认为LOG_USER,指定facilityserver_audit_syslog_ident:设置ident,作为每个syslog记录的一部分server_audit_syslog_info:指定的info字符串将添加到syslog记录server_audit_syslog_priority:定义记录日志的syslogd priorityserver_audit_excl_users:该列表的用户行为将不记录,connect将不受该设置影响server_audit_mode:标识版本,用于开发测试

5. Uninstall

mysql> UNINSTALL PLUGIN server_audit;mysql> show variables like ‘%audit%‘;Empty set (0.00 sec)

Prevents the Server_audit plugin from being uninstalled and needs to be added to the configuration file:
[Mysqld]
Server_audit=force_plus_permanent
Restart MySQL in effect

"MySQL" MySQL audit operation Record

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.