当前位置:网站首页>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 &
边栏推荐
- 【acwing】836. Merge sets
- 669. 修剪二叉搜索树 ●●
- Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
- 2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
- 【acwing】240. food chain
- Neural networks and deep learning Chapter 5: convolutional neural networks reading questions
- Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
- Setting up redis cluster cluster under Windows
- Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
- Neural networks and deep learning Chapter 3: linear model reading questions
猜你喜欢
MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP
AutoCAD - feature matching
JVM 原理和流程简介
[groovy] closure closure (customize closure parameters | customize a single closure parameter | customize multiple closure parameters | specify the default value of closure parameters)
[groovy] closure (Introduction to closure class closure | this, owner, delegate member assignment and source code analysis)
What are the building energy-saving software
AutoCAD - graphic input and output
A survey of automatic speech recognition (ASR) research
2022 American College Students' mathematical modeling ABCDEF problem thinking /2022 American match ABCDEF problem analysis
数论函数及其求和 待更新
随机推荐
[Chongqing Guangdong education] National Open University 2047t commercial bank operation and management reference test in autumn 2018
Neural networks and deep learning Chapter 3: linear model reading questions
Interface joint commissioning test script optimization V5.0 (end)
Rip notes [rip three timers, the role of horizontal segmentation, rip automatic summary, and the role of network]
[groovy] closure (closure call is associated with call method | call () method is defined in interface | call () method is defined in class | code example)
2021 electrician cup (the 12th "China Society of electrical engineering Cup" National Undergraduate electrician mathematical modeling) detailed ideas + codes + references
What are the building energy-saving software
AutoCAD - continuous annotation
[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)
SQL set operation
2022-2028 global and Chinese equipment as a Service Market Research Report
Is $20billion a little less? Cisco is interested in Splunk?
An article takes you to thoroughly understand descriptors
介绍汉明距离及计算示例
The first topic of ape Anthropology
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
AutoCAD - Document Management
Special information | finance, accounting, audit - 22.1.23
PHP reads the INI file and writes the modified content
CUDA Programming atomic operation atomicadd reports error err:msb3721, return code 1