mysql record operation log

Divided into two ways, file logging and database logging, with the same effect.
One file logging database operation log:
first enter mysql input command

show variables like 'gen%';

Insert picture description here
Whether general_log is open or closed, and where is the general_log file of this account.
If it is not open, please set it to open first

set global general_log=ON;
``
查看log:
cat /目录/日志.log
二 数据库自己记录日志
```bash
show variables like '%log_output%';

The default is FILE, changed to TABLE

set  global log_output='TABLE';

After that, you can view the database operation records through the following two sentences
:

select * from mysql.general_log;

You will see that the log has been recorded in the database

Insert picture description here
Because the database keeps recording logs will increase the pressure, it is recommended to use files to record

set  global log_output='FILE';

truncate table mysql.general_log;

Guess you like

Origin blog.csdn.net/kevlin_V/article/details/106431521