当前位置:网站首页>mysql審計日志歸檔
mysql審計日志歸檔
2022-07-05 04:49:00 【huryer】
mysql審計日志歸檔
1、開啟審計日志
# 啟動審計,在mysql中執行命令:
set global general_log=on;
set global log_timestamps=SYSTEM;
set global general_log_file='db-1.log';
2、審計日志歸檔
創建歸檔備份目錄
# 創建歸檔備份目錄
mkdir -p /data/backup/audit
cd /data/backup/audit
創建審計日志歸檔脚本
vim mysql_aud_backup.sh
脚本內容如下:
#!/bin/bash
# mysql審計日志歸檔脚本
# 保留最近30天審計日志
# 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
# 設置日志文件路徑
aud_folder=/data/mysql/data
backup_folder=/data/backup/audit
# 指定審計日志文件名
fn=db-1.log
dt=$(date +%Y%m%d)
# 切換到審計日志路徑
cd $aud_folder
# 歸檔審計日志
mv $fn $fn.$dt
mysqladmin flush-logs -u root -p'my_sql_pwd'
mv $fn.$dt $backup_folder/
# 保留30天內的審計日志
find $backup_folder/ -mtime +30 -name "$fn.*" |xargs rm -f
添加可執行權限
# 添加可執行權限
chmod +x mysql_aud_backup.sh
3、添加計劃任務
# 添加計劃任務
crontab -e
0 1 * * * nohup sh /data/backup/audit/mysql_aud_backup.sh &
边栏推荐
- Raki's notes on reading paper: soft gazetteers for low resource named entity recognition
- Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
- A survey of automatic speech recognition (ASR) research
- flutter 对象和列表
- Detailed introduction of OSPF header message
- Practice | mobile end practice
- XSS injection
- Observable time series data downsampling practice in Prometheus
- Neural networks and deep learning Chapter 3: linear model reading questions
- Special information | real estate and office buildings - 22.1.9
猜你喜欢
![[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)](/img/1b/1fa2ebc9a6c5d271c9b39f5e508fb0.jpg)
[groovy] closure (Introduction to closure class closure | closure parametertypes and maximumnumberofparameters member usage)

XSS injection

Matplotlib draws three-dimensional scatter and surface graphs

【Leetcode】1352. 最后 K 个数的乘积

Discussion on the dimension of confrontation subspace

SQL set operation

2021 huashubei mathematical modeling idea + reference + paper
![[groovy] closure (closure call | closure default parameter it | code example)](/img/61/754cee9a940fd4ecd446b38c2f413d.jpg)
[groovy] closure (closure call | closure default parameter it | code example)
![[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)](/img/90/0cf08ae6fea61891e3e1fdf29d310c.jpg)
[groovy] closure (closure parameter binding | curry function | rcurry function | ncurry function | code example)

3 minutes learn to create Google account and email detailed tutorial!
随机推荐
AutoCAD - feature matching
XSS injection
PHP reads the INI file and writes the modified content
SQL set operation
Thematic information | carbon, carbon neutrality, low carbon, carbon emissions - 22.1.9
JMeter -- distributed pressure measurement
49 pictures and 26 questions explain in detail what is WiFi?
[groovy] closure (closure as function parameter | code example)
包 类 包的作用域
Advanced length of redis -- deletion strategy, master-slave replication, sentinel mode
English topic assignment (26)
AutoCAD - command repetition, undo and redo
Live broadcast preview | container service ack elasticity prediction best practice
You Li takes you to talk about C language 7 (define constants and macros)
猿人学第一题
On-off and on-off of quality system construction
Flink集群配置
Data security -- 14 -- Analysis of privacy protection governance
2022-2028 global and Chinese equipment as a Service Market Research Report
How can CIOs use business analysis to build business value?