MySQL General Log
MySQL主从复制:https://blog.csdn.net/a18792721831/article/details/146117935Binlog 的特点是只记录数据修改语句,有时可能需要记录客户端执行的每条SQL语句,General Log 会记录所有的SQL。_mysql 开启generallog
文章信息
- 原文链接:https://jiayq.blog.csdn.net/article/details/146607343
- 发布时间:2025-03-28 17:58:28
- 阅读量:652
- 分类:mysql专栏收录该内容, 订阅专栏
- 标签:#mysql, #数据库, #General Log, #log_output
摘要
文章浏览阅读652次,点赞4次,收藏5次。MySQL主从复制:https://blog.csdn.net/a18792721831/article/details/146117935Binlog 的特点是只记录数据修改语句,有时可能需要记录客户端执行的每条SQL语句,General Log 会记录所有的SQL。_mysql 开启generallog
MySQL General Log
MySQL General Log
- General Log 的开启
- General Log 的用法
- log_output 参数
MySQL主从复制:https://blog.csdn.net/a18792721831/article/details/146117935
MySQL Binlog:https://blog.csdn.net/a18792721831/article/details/146606305
MySQL General Log:https://blog.csdn.net/a18792721831/article/details/146607343
MySQL Slow Log:https://blog.csdn.net/a18792721831/article/details/147166971
MySQL Error Log:https://blog.csdn.net/a18792721831/article/details/147167038
MySQL Redo Log: https://blog.csdn.net/a18792721831/article/details/149862528
MySQL Undo Log: https://blog.csdn.net/a18792721831/article/details/149880355
Binlog 的特点是只记录数据修改语句,有时可能需要记录客户端执行的每条SQL语句,General Log 会记录所有的SQL
General Log 的开启
使用 select @@general_log;查看
使用 set glogbal general_log_file = "/var/log/mysql/general_log.log"设置general_log的保存位置
使用set global general_log=on;开启general_log
在服务端查看是否有general_log
General Log 的用法
执行一句SQLselect 'test_general_log';查看是否被记录到了general_log中了
一模一样。
如果需要永久生效,需要在配置文件的[mysqld]中配置
1
2
general_log=on
general_log_file=/var/log/mysql/general_log.log
log_output 参数
另外,可以定义 General_log的输出方式,并由log_output参数控制(该参数对Slow Log 同样生效)。
log_output的几个值对应的效果:
- TABLE:将记录保存在表中
- FILE:讲记录保存在日志文件中
- NONE:禁用日志记录
TABLE和FILE可以同时开启
调整为 TABLE
执行一条sql
查看file
之后的就不在记录了
设置同时记录
set global log_output="TABLE,FILE";
查看file










