1 内核及公共消息日志:/var/log/messages2
3 计划任务日志:/var/log/cron4
5 系统引导日志:/var/log/dmesg6
7 邮件系统日志:/var/log/maillog8
9 用户登录日志:/var/log/lastlog、 /var/log/secure、 /var/log/wtmp、 /var/run/btmp10
11 vim /etc/rsyslog.conf //查看日志文件配置信息
12 vim messages //查看系统日志文件
开启 general log 将所有到达MySQL Server的SQL语句记录
show variables like 'general_log'; --查看日志是否开启
set global general_log=on; --开启日志功能
show variables like'general_log_file'; --看看日志文件保存位置
set global general_log_file='tmp/general.lg'; --设置日志文件保存位置
show variables like'log_output'; --看看日志输出类型 table或file
set global log_output='table'; --设置输出类型为 table
set global log_output='file'; --设置输出类型为file
show variables like ‘%log%’;
Binlog 记录了所有的DDL和DML(除了数据查询语句)语句(记录mysql内部增删改等对mysql数据库有更新的内容的记录(对数据库的改动),对数据库的查询select或show等不会被binlog日志记录),以事件形式记录,还包含语句所执行的消耗的时间,MySQL的二进制日志是事务安全型的。
show variables like '%log_bin%'; --查看binlog日志设置
show master logs;
show master status;
flush logs;
reset master;
show binlog eventsin 'mysql-bin.000002'; --查看binlog日志
show binlog events [IN'log_name'] [FROM pos] [LIMIT [offset,] row_count];
show binlog eventsin 'mysql-bin.000001'\G
指定查询 mysql-bin.000002这个文件,从pos点:624开始查起,偏移2行(即中间跳过2个)查询10条(即10条语句)。
show binlog eventsin 'mysql-bin.000002' from 624 limit 2,10\G;
查询主库binlog和pos点
show variables like '%log_bin%'; --查看binlog日志设置cat /var/lib/mysql/mysql-bin.index
mysqlbinlog --no-defaults /var/lib/mysql/mysql-bin.000003
show binlog events in 'm