当前位置:网站首页>MySQL audit log archiving
MySQL audit log archiving
2022-07-05 04:49:00 【huryer】
mysql Audit log archiving
1、 Open audit log
# Start audit , stay mysql Middle execution command :
set global general_log=on;
set global log_timestamps=SYSTEM;
set global general_log_file='db-1.log';
2、 Audit log archiving
Create an archive backup directory
# Create an archive backup directory
mkdir -p /data/backup/audit
cd /data/backup/audit
Create audit log archive script
vim mysql_aud_backup.sh
The script is as follows :
#!/bin/bash
# mysql Audit log archive script
# Keep recent 30 Day audit log
# crontab -l
# 0 1 * * * nohup sh /data/backup/audit/mysql_aud_backup.sh &
export PATH=.:$PATH:/usr/local/mysql-5.7.34-el7-x86_64/bin
# Set log file path
aud_folder=/data/mysql/data
backup_folder=/data/backup/audit
# Specify the audit log file name
fn=db-1.log
dt=$(date +%Y%m%d)
# Switch to the audit log path
cd $aud_folder
# Archive audit logs
mv $fn $fn.$dt
mysqladmin flush-logs -u root -p'my_sql_pwd'
mv $fn.$dt $backup_folder/
# Retain 30 Audit log within days
find $backup_folder/ -mtime +30 -name "$fn.*" |xargs rm -f
Add executable rights
# Add executable rights
chmod +x mysql_aud_backup.sh
3、 Add scheduled tasks
# Add scheduled tasks
crontab -e
0 1 * * * nohup sh /data/backup/audit/mysql_aud_backup.sh &
边栏推荐
- 包 类 包的作用域
- Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
- Stage experience
- 中国溶聚丁苯橡胶(SSBR)行业研究与预测报告(2022版)
- Interface joint commissioning test script optimization V5.0 (end)
- AutoCAD - Center zoom
- xss注入
- Data security -- 14 -- Analysis of privacy protection governance
- Flutter 小技巧之 ListView 和 PageView 的各种花式嵌套
- 2022 thinking of mathematical modeling a problem of American college students / analysis of 2022 American competition a problem
猜你喜欢
Use assimp library to read MTL file data
【acwing】240. food chain
【acwing】528. cheese
2022-2028 global and Chinese video coding and transcoding Market Research Report
AutoCAD - command repetition, undo and redo
CSDN body auto generate directory
Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation
Manually implement heap sorting -838 Heap sort
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
程序员应该怎么学数学
随机推荐
Leetcode 222 number of nodes of complete binary tree
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
Looking at Chinese science and technology from the Winter Olympics: what is the mystery of the high-speed camera that the whole people thank?
Pointer function (basic)
Neural networks and deep learning Chapter 6: Circular neural networks reading questions
2022-2028 global and Chinese FPGA prototype system Market Research Report
3 minutes learn to create Google account and email detailed tutorial!
2021 Higher Education Club Cup mathematical modeling national tournament ABCD problem - problem solving ideas
Official announcement! The third cloud native programming challenge is officially launched!
jmeter -- 分布式压测
2021 electrician cup idea + code - photovoltaic building integration plate index development trend analysis and prediction: prediction planning issues
猿人学第一题
【Leetcode】1352. 最后 K 个数的乘积
The difference between bundle, chunk and module
Scope of package class package
AutoCAD - stretching
2022-2028 global and Chinese video coding and transcoding Market Research Report
Understand encodefloatrgba and decodefloatrgba
An article takes you to thoroughly understand descriptors
windows下Redis-cluster集群搭建