1、查看“查询日志”功能是否开启

SHOW VARIABLES LIKE 'general%';

745552880

general_log:查询日志功能开关标志,默认关闭OFF。

general_log_file:查询日志功能开启后,日志文件保存的位置。

2、如果该功能是关闭的,可以通过下面这条语句开启

set GLOBAL general_log='ON';

image-20200214120959574

3、查看开启结果

SHOW VARIABLES LIKE 'general_log';

image-20200214121116082

4、查看查询日志

[root@bogon mysql]# head /var/lib/mysql/bogon.log

2020-02-14T04:27:59.986158Z         9 Init DB   snort
2020-02-14T04:27:59.986481Z         9 Query     SELECT vseq FROM `schema`
2020-02-14T04:28:00.008261Z         9 Init DB   snort
2020-02-14T04:28:00.008667Z         9 Query     SELECT vseq FROM `schema`
2020-02-14T04:28:00.010015Z         9 Query     SELECT ip_src FROM iphdr LIMIT 0, 1
2020-02-14T04:28:00.010972Z         9 Query     SELECT
                        TABLE_NAME,
                        CASE WHEN TABLE_TYPE = 'VIEW' THEN 'V' ELSE 'T' END
                FROM INFORMATION_SCHEMA.TABLES
[root@bogon mysql]#

标签: none

添加新评论