log_error配置。general_log=1,建议开发环境使用。slow_query_log=1及long_query_time。log_bin,支持ROW/STATEMENT/MIXED格式。logrotate自动轮转,配置文件示例(/etc/logrotate.d/mysql):/var/log/mysql/*.log {
daily
rotate 7
compress
missingok
create 640 mysql adm
}
find /var/log/mysql/ -type f -mtime +30 -exec rm {} \;。tail -f /var/log/mysql/error.log。grep 'error' /var/log/mysql/error.log。mysqlbinlog /var/log/mysql/mysql-bin.000001。mysqldumpslow /var/log/mysql/slow.log。server_audit,记录连接、查询等操作,配置文件中设置server_audit_events。sync_binlog=1确保数据安全,或根据负载调整。chown mysql:mysql /var/log/mysql/。