当前位置:网站首页>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 &
边栏推荐
- Special information | finance, accounting, audit - 22.1.23
- 775 Div.1 C. Tyler and strings combinatorial mathematics
- AutoCAD - workspace settings
- 介绍汉明距离及计算示例
- Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
- 2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis
- Neural network and deep learning Chapter 1: introduction reading questions
- An article takes you to thoroughly understand descriptors
- [PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
- Chapter 6 text processing tools for shell programming (awk)
猜你喜欢

Wenet: E2E speech recognition tool for industrial implementation

AutoCAD -- dimension break

2022 U.S. college students' mathematical modeling e problem ideas / 2022 U.S. game e problem analysis

取余操作是一个哈希函数

How should programmers learn mathematics

PostgreSQL 超越 MySQL,“世界上最好的编程语言”薪水偏低

Understand encodefloatrgba and decodefloatrgba

An article takes you to thoroughly understand descriptors

2022 American College Students' mathematical modeling ABCDEF problem thinking /2022 American match ABCDEF problem analysis

2022-2028 global and Chinese FPGA prototype system Market Research Report
随机推荐
AutoCAD - command repetition, undo and redo
3 minutes learn to create Google account and email detailed tutorial!
#775 Div.1 B. Integral Array 数学
Rip notes [rip message security authentication, increase of rip interface measurement]
[groovy] closure (closure call | closure default parameter it | code example)
AutoCAD - scaling
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
AutoCAD - stretching
2022-2028 global and Chinese video coding and transcoding Market Research Report
Setting up redis cluster cluster under Windows
[groovy] closure (closure as function parameter | code example)
#775 Div.1 C. Tyler and Strings 组合数学
CSDN正文自动生成目录
猿人学第一题
2022-2028 global and Chinese virtual data storage Market Research Report
Pointer function (basic)
2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
Use assimp library to read MTL file data
Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
669. 修剪二叉搜索树 ●●