当前位置:网站首页>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 &
边栏推荐
- Flutter tips: various fancy nesting of listview and pageview
- 次小生成树
- Raki's notes on reading paper: code and named entity recognition in stackoverflow
- Neural network and deep learning Chapter 1: introduction reading questions
- CSDN正文自动生成目录
- Invalid bound statement (not found) in idea -- problem solving
- Neural networks and deep learning Chapter 3: linear model reading questions
- AutoCAD - lengthening
- flutter 对象和列表
- Detailed introduction of OSPF header message
猜你喜欢
Live broadcast preview | container service ack elasticity prediction best practice
Managed service network: application architecture evolution in the cloud native Era
Number theoretic function and its summation to be updated
2022-2028 global and Chinese FPGA prototype system Market Research Report
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
Reading and visualization of DICOM, MHD and raw files in medical imaging
2022-2028 global and Chinese equipment as a Service Market Research Report
【acwing】240. food chain
计组笔记(1)——校验码、原补码乘除计算、浮点数计算
随机推荐
Neural networks and deep learning Chapter 5: convolutional neural networks reading questions
中国艾草行业研究与投资前景预测报告(2022版)
JVM 原理和流程简介
A survey of automatic speech recognition (ASR) research
Rk3399 platform development series explanation (network debugging) 7.29 summary of network performance tools
mysql审计日志归档
PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
Group counting notes (1) - check code, original complement multiplication and division calculation, floating point calculation
Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
MD5绕过
次小生成树
Minor spanning tree
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
The 22nd Spring Festival Gala, an immersive stage for the yuan universe to shine into reality
flutter 对象和列表
包 类 包的作用域
Setting up redis cluster cluster under Windows
On-off and on-off of quality system construction