Lab 13: Audit Logging
Overview
Step 1: MySQL — Enable Audit Log Plugin
docker run -d --name mysql-lab \
-e MYSQL_ROOT_PASSWORD=rootpass \
mysql:8.0
for i in $(seq 1 30); do docker exec mysql-lab mysql -uroot -prootpass -e "SELECT 1" 2>/dev/null && break || sleep 2; done
docker exec mysql-lab mysql -uroot -prootpass <<'EOF'
-- Install the audit log plugin
INSTALL PLUGIN audit_log SONAME 'audit_log.so';
-- Configure audit logging
SET GLOBAL audit_log_policy = 'ALL'; -- Log everything
SET GLOBAL audit_log_format = 'JSON'; -- JSON format for easy parsing
SET GLOBAL audit_log_rotate_on_size = 104857600; -- Rotate at 100MB
-- Verify plugin is active
SELECT PLUGIN_NAME, PLUGIN_STATUS FROM information_schema.PLUGINS
WHERE PLUGIN_NAME = 'audit_log';
-- Check current audit settings
SHOW VARIABLES LIKE 'audit_log%';
EOFStep 2: Generate Audit Events
Step 3: Read and Parse MySQL Audit Log
Step 4: Filter Audit Log by Policy
Step 5: PostgreSQL pgaudit Setup
Step 6: Generate Audit Events in PostgreSQL
Step 7: Read and Parse PostgreSQL Audit Log
Step 8: Capstone — Audit Compliance Report
Summary
Feature
MySQL
PostgreSQL
Log Level
Key Takeaways
Last updated
