当前位置:网站首页>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 &
边栏推荐
- 2021 higher education social cup mathematical modeling national tournament ABCD questions - problem solving ideas - Mathematical Modeling
- MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP
- History of web page requests
- flutter 对象和列表
- 包 类 包的作用域
- Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
- Flink cluster configuration
- Function overloading
- Construction d'un Cluster redis sous Windows
- Cookie learning diary 1
猜你喜欢
2021 huashubei mathematical modeling idea + reference + paper
[goweb development] Introduction to authentication modes based on cookies, sessions and JWT tokens
Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
MySQL in-depth learning - index creation and deletion, index design principles, index failure scenarios, query optimization, index push down ICP
程序员应该怎么学数学
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
【acwing】837. Number of connected block points
Autocad-- Real Time zoom
windows下Redis-cluster集群搭建
windows下Redis-cluster集群搭建
随机推荐
AutoCAD - command repetition, undo and redo
flutter 对象和列表
[crampon programming] lintcode decoding Encyclopedia - 872 termination process
Hypothesis testing -- learning notes of Chapter 8 of probability theory and mathematical statistics
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)
Leetcode hot topic Hot 100 day 33: "subset"
Autocad-- dynamic zoom
Emlog blog theme template source code simple good-looking responsive
取余操作是一个哈希函数
Function overloading
QT Bluetooth: a class for searching Bluetooth devices -- qbluetooth devicediscoveryagent
2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
3 minutes learn to create Google account and email detailed tutorial!
2022 thinking of Mathematical Modeling B problem of American college students / analysis of 2022 American competition B problem
On-off and on-off of quality system construction
Special information | real estate and office buildings - 22.1.9
计组笔记(1)——校验码、原补码乘除计算、浮点数计算
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator
AutoCAD - Document Management
Mode in BST (binary tree & Notes on question brushing)