当前位置:网站首页>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 &
边栏推荐
- Chapter 6 text processing tools for shell programming (awk)
- 2022-2028 global and Chinese equipment as a Service Market Research Report
- Variable category (automatic, static, register, external)
- Scope of package class package
- 775 Div.1 C. Tyler and strings combinatorial mathematics
- 2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
- 54. 螺旋矩阵 & 59. 螺旋矩阵 II ●●
- 2021 electrician Cup - high speed rail traction power supply system operation data analysis and equivalent modeling ideas + code
- Function overloading
- The difference between bundle, chunk and module
猜你喜欢
![[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)](/img/36/c4206a95c007e41df628d99e06ba18.jpg)
[groovy] closure (closure parameter list rule | default parameter list | do not receive parameters | receive custom parameters)

10 programming habits that web developers should develop

AutoCAD - isometric annotation

取余操作是一个哈希函数

计组笔记(1)——校验码、原补码乘除计算、浮点数计算
![[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator](/img/cc/06580ce7b553182968d273841a78b4.jpg)
[AI bulletin 20220211] the hard core up owner has built a lidar and detailed AI accelerator

3 minutes learn to create Google account and email detailed tutorial!

解密函数计算异步任务能力之「任务的状态及生命周期管理」

The principle of attention mechanism and its application in seq2seq (bahadanau attention)

Official announcement! The third cloud native programming challenge is officially launched!
随机推荐
包 类 包的作用域
PHP reads the INI file and writes the modified content
History of web page requests
次小生成树
2022 thinking of mathematical modeling D problem of American college students / analysis of 2022 American competition D problem
An article takes you to thoroughly understand descriptors
49 pictures and 26 questions explain in detail what is WiFi?
[PCL self study: feature9] global aligned spatial distribution (GASD) descriptor (continuously updated)
Interface joint commissioning test script optimization V5.0 (end)
XSS injection
Key review route of probability theory and mathematical statistics examination
Setting up redis cluster cluster under Windows
介绍汉明距离及计算示例
Wenet: E2E speech recognition tool for industrial implementation
2022-2028 global and Chinese video coding and transcoding Market Research Report
【Leetcode】1352. 最后 K 个数的乘积
Private collection project practice sharing [Yugong series] February 2022 U3D full stack class 006 unity toolbar
How should programmers learn mathematics
Leetcode 222 number of nodes of complete binary tree
Inline built-in function