Wazuh MySQL Integration: Security & Log Detection

Databases store some of an organization’s most valuable information, making them one of the most attractive targets for attackers. Whether you’re running a small web application or a large enterprise environment, a compromised MySQL server can expose customer data, financial records, credentials, and business-critical applications.

Because of this, database security requires continuous visibility into authentication events, configuration changes, user activity, and potential indicators of compromise.

Wazuh provides an effective way to monitor MySQL by collecting database-related logs, correlating security events, detecting suspicious behavior, and generating actionable alerts from a centralized platform.

Rather than manually reviewing database logs after an incident occurs, security teams can continuously analyze MySQL activity alongside operating system events, network logs, and endpoint telemetry to identify attacks much earlier.

Integrating Wazuh with MySQL also allows organizations to improve threat detection while supporting compliance frameworks that require database auditing and log retention.

Since Wazuh combines log analysis, File Integrity Monitoring (FIM), Security Configuration Assessment (SCA), vulnerability detection, and active response capabilities, it provides much broader visibility than traditional database monitoring tools alone.

Why monitor MySQL with Wazuh?

Modern cyberattacks frequently target databases after an attacker gains initial access to a server.

Monitoring MySQL helps security teams detect abnormal login attempts, unauthorized privilege changes, suspicious SQL activity, database configuration modifications, and potential data exfiltration attempts before they become major security incidents.

Unlike standalone database auditing solutions, Wazuh correlates MySQL events with system logs, authentication logs, firewall activity, and endpoint telemetry, providing a much more complete picture of an attack.

Benefits of integrating Wazuh with MySQL

A properly configured Wazuh-MySQL integration offers several advantages:

  • Centralized monitoring for MySQL and operating system logs
  • Detection of brute-force attacks against database accounts
  • Visibility into administrative actions and privilege changes
  • File Integrity Monitoring for MySQL configuration files
  • Correlation of database events with endpoint and network activity
  • Faster incident detection through customizable alert rules
  • Improved compliance reporting for regulatory standards
  • Long-term searchable log storage and dashboards

These capabilities help reduce investigation time while giving analysts better context around suspicious database activity.

What readers will learn

By the end of this guide, you’ll understand:

  • How Wazuh integrates with MySQL
  • Which MySQL logs should be monitored
  • How Wazuh collects and analyzes database events
  • Which Wazuh components participate in database monitoring
  • Common security threats that can be detected
  • Best practices for securing MySQL with Wazuh
  • How to create effective detection rules for database events

 Understanding Wazuh MySQL Integration

Wazuh integrates with MySQL primarily through log collection and file monitoring rather than by directly connecting to the database engine itself.

The Wazuh agent monitors MySQL log files and configuration files on the database server, forwards relevant events to the Wazuh Manager, and applies rules that detect suspicious or malicious behavior.

This approach keeps the monitoring lightweight while providing deep visibility into authentication events, configuration changes, database errors, administrative actions, and potential attacks.

What the integration does

The integration enables Wazuh to continuously monitor MySQL-related activity, including:

  • User authentication
  • Failed login attempts
  • Database errors
  • Administrative operations
  • Query activity (when enabled)
  • Configuration modifications
  • Service availability
  • Database file changes
  • Security policy violations

Collected events are normalized by Wazuh decoders, matched against detection rules, and presented in the Wazuh Dashboard where analysts can investigate alerts.

For organizations using SIEM workflows, this creates a centralized security monitoring solution that combines database activity with operating system logs, endpoint telemetry, cloud services, and network security events.

How Wazuh collects MySQL logs

Most deployments configure the Wazuh agent to monitor MySQL log files using Logcollector.

Typical monitored log files include:

  • Error log
  • General query log
  • Slow query log
  • Binary log metadata (where applicable)
  • Audit plugin logs
  • MySQL authentication events
  • System authentication logs related to MySQL

Whenever a new log entry appears, the Wazuh agent immediately forwards the event to the manager for decoding, rule matching, indexing, and visualization.

If MySQL configuration files are also monitored with File Integrity Monitoring (FIM), Wazuh detects unauthorized modifications and alerts administrators whenever critical settings change.

Related Guide: How to Configure ossec.conf for Log Monitoring in Wazuh

Supported MySQL log types

The exact logs available depend on the MySQL configuration, but Wazuh commonly monitors:

  • Error logs
  • General query logs
  • Slow query logs
  • Audit logs (Enterprise Audit or community audit plugins)
  • Authentication logs
  • Replication logs
  • Binary log status events
  • Configuration file changes
  • Operating system service logs

Enabling additional logging increases visibility but should be balanced against storage requirements and database performance.

Supported operating systems

Wazuh can monitor MySQL servers running on nearly every major operating system supported by both products, including:

  • Linux (Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, CentOS, SUSE)
  • Windows Server
  • macOS (primarily development environments)
  • Cloud virtual machines
  • Containerized environments
  • Kubernetes deployments

Related Guide: How to Monitor Kubernetes Using Wazuh

Wazuh components involved

Several Wazuh components work together during MySQL monitoring.

Wazuh Agent

The Wazuh agent resides on the MySQL server and performs tasks such as:

  • Reading MySQL log files
  • Monitoring configuration changes
  • Collecting system information
  • Performing File Integrity Monitoring
  • Sending events securely to the manager

Since processing occurs close to the data source, organizations can monitor large environments efficiently.

Wazuh Manager

The manager receives events from agents and performs:

  • Event normalization
  • Rule evaluation
  • Alert generation
  • Correlation across multiple systems
  • Active response (if configured)

It acts as the central analysis engine for all collected MySQL events.

File Integrity Monitoring (FIM)

FIM watches important database-related files, including:

  • my.cnf
  • mysqld.cnf
  • SSL certificates
  • Database configuration directories
  • Plugin files

Unexpected modifications may indicate unauthorized administrative activity or malware attempting to weaken database security.

Related Guide: How to Configure File Integrity Monitoring (FIM) in Wazuh

Log Analysis Engine

The log analysis engine processes incoming MySQL events by:

  • Parsing raw logs
  • Extracting important fields
  • Applying decoders
  • Matching detection rules
  • Assigning alert severity
  • Creating searchable security events

This automation eliminates the need to manually inspect large database log files.

Rules and Decoders

Rules and decoders transform raw MySQL log entries into meaningful alerts.

For example, they can detect:

  • Multiple failed logins
  • New administrator creation
  • Privilege modifications
  • Configuration changes
  • SQL errors
  • Suspicious database activity

Organizations can also create custom rules tailored to their environment.

Related Guide: How to Create Custom Detection Rules in Wazuh (With Examples)

Dashboard

The Wazuh Dashboard provides analysts with:

  • Searchable MySQL events
  • Alert timelines
  • Severity filtering
  • Visual dashboards
  • Correlated investigations
  • Compliance reporting
  • Historical log analysis

Security teams can quickly investigate suspicious database activity without manually searching log files.


Why Monitor MySQL with Wazuh?

MySQL is often one of the most targeted services in an organization’s infrastructure because it stores sensitive business information.

Continuous monitoring enables security teams to detect attacks early, investigate incidents faster, and maintain compliance with regulatory standards.

Detect Unauthorized Access

Unauthorized database access is one of the earliest indicators of compromise.

Wazuh can alert when:

  • Unknown users authenticate
  • Access occurs outside business hours
  • Remote connections originate from unexpected hosts
  • Dormant accounts become active
  • Service accounts authenticate abnormally

Correlating these events with operating system authentication logs provides valuable context during investigations.

Monitor Failed Login Attempts

Repeated authentication failures frequently indicate:

  • Password spraying
  • Credential stuffing
  • Brute-force attacks
  • Automated scanning
  • Misconfigured applications

Wazuh can identify repeated failures across multiple systems and generate alerts before attackers successfully gain database access.

The OWASP Authentication Cheat Sheet recommends monitoring authentication failures as part of a strong defense-in-depth strategy.

Audit Administrative Activity

Database administrators routinely perform legitimate maintenance, but attackers also seek elevated database privileges.

Monitoring administrative actions provides visibility into:

  • User creation
  • User deletion
  • Password changes
  • Database creation
  • Database deletion
  • Permission assignments
  • Administrative logins

Maintaining detailed audit records significantly improves forensic investigations after security incidents.

Detect Privilege Escalation

Privilege escalation inside MySQL can allow attackers to gain full administrative control over the database.

Important events include:

  • Granting global privileges
  • SUPER privilege assignments
  • New root-level accounts
  • Permission inheritance changes
  • Role modifications

These events should generate high-priority alerts for immediate investigation.

Identify Suspicious Queries

Although organizations may not log every SQL statement due to performance considerations, monitoring selected query logs can reveal:

  • Mass table exports
  • Unexpected DELETE operations
  • Bulk UPDATE commands
  • Schema modifications
  • Sensitive table access
  • Enumeration attempts

Database Activity Monitoring (DAM) guidance from security practitioners consistently emphasizes query monitoring for detecting insider threats and data exfiltration attempts.

Monitor Configuration Changes

Attackers often modify database configuration files to:

  • Disable logging
  • Weaken authentication
  • Enable insecure plugins
  • Reduce auditing
  • Change network exposure

Using Wazuh File Integrity Monitoring ensures administrators are alerted whenever critical MySQL configuration files change unexpectedly.

Meet Compliance Requirements

Many security regulations require organizations to monitor database access and retain audit logs.

PCI DSS

Organizations handling payment card data must monitor access to cardholder databases, generate audit logs, and review security events regularly.

Wazuh helps satisfy several logging and monitoring requirements by centralizing database audit events.

HIPAA

Healthcare organizations must maintain audit controls capable of recording system activity involving electronic protected health information (ePHI).

Continuous MySQL monitoring helps demonstrate accountability and detect unauthorized access to sensitive medical data.

GDPR

Organizations processing personal data should maintain appropriate security monitoring and detect unauthorized access to databases containing personal information.

Monitoring MySQL logs improves visibility into potential data breaches and supports incident investigations.

ISO 27001

ISO 27001 encourages organizations to implement logging, monitoring, event correlation, and security incident detection as part of an Information Security Management System (ISMS).

Centralized MySQL monitoring aligns well with these security controls.

SOC 2

SOC 2 emphasizes continuous monitoring, change management, audit logging, and security event detection.

Database activity monitoring provides evidence that organizations maintain visibility into systems handling sensitive customer data.


How Wazuh Monitors MySQL

Wazuh monitors MySQL by collecting database log files, decoding the log entries into structured events, matching them against detection rules, and generating alerts when suspicious or predefined conditions are met.

These alerts are then indexed and displayed in the Wazuh Dashboard, where analysts can investigate database activity alongside endpoint, network, and operating system events.

Unlike database monitoring tools that rely on direct database connections, Wazuh primarily uses its agent-based architecture to monitor log files and configuration changes.

This approach minimizes performance overhead while still providing comprehensive visibility into MySQL security events.

Log Collection

The monitoring process begins with the Wazuh Agent, which continuously watches designated MySQL log files for new entries.

Commonly monitored files include:

  • MySQL error log
  • General query log
  • Slow query log
  • Audit logs
  • MySQL service logs
  • Operating system authentication logs related to MySQL

The Wazuh Logcollector component reads newly appended log entries in near real time and securely forwards them to the Wazuh Manager for analysis.

Depending on your environment, log monitoring can be configured using the <localfile> section of the ossec.conf file.

Related Guide: How to Configure ossec.conf for Log Monitoring in Wazuh

Monitoring logs as they are written allows security teams to identify suspicious database activity almost immediately rather than waiting for scheduled scans or manual reviews.

Log Decoding

Raw MySQL log entries are often unstructured or semi-structured, making them difficult to analyze directly.

After receiving an event, the Wazuh Manager uses decoders to extract important information such as:

  • Username
  • Client IP address
  • Timestamp
  • Database name
  • SQL operation
  • Error code
  • Connection status
  • Authentication result

The decoded information is normalized into a consistent format so it can be processed by detection rules regardless of the operating system or log source.

Organizations with custom applications or plugins can also create their own decoders for proprietary log formats.

Related Guide: How to Create Custom Detection Rules in Wazuh (With Examples)

Rule Matching

Once a log entry has been decoded, Wazuh evaluates it against its rule engine.

Rules can identify events such as:

  • Failed authentication attempts
  • Multiple login failures
  • New administrative users
  • Privilege modifications
  • Suspicious SQL activity
  • Configuration changes
  • Replication failures
  • Service crashes

Rules can also correlate multiple events over time.

For example, several failed login attempts followed by a successful authentication from the same IP address may indicate a successful brute-force attack.

Custom rules allow organizations to tailor detections to their own database policies, application behavior, and security requirements.

Alert Generation

When a rule matches an event, Wazuh generates a security alert.

Each alert includes valuable investigation details such as:

  • Alert severity
  • Rule ID
  • Event timestamp
  • Source IP address
  • Database user
  • Hostname
  • Log message
  • Description of the detected activity

Security teams can adjust rule severity levels based on organizational risk tolerance, allowing high-priority database events to stand out during incident response.

Dashboard Visualization

Processed events are indexed and displayed in the Wazuh Dashboard, giving analysts a centralized view of MySQL activity.

Dashboard features include:

  • Searchable database events
  • Timeline visualizations
  • Alert severity filters
  • Event correlation
  • Historical investigations
  • Compliance reporting
  • Custom dashboards

Because MySQL events appear alongside endpoint, firewall, authentication, and cloud logs, analysts gain valuable context that would otherwise require switching between multiple security tools.

Active Response (Optional)

For organizations that want automated incident response, Wazuh can trigger Active Response actions when specific database threats are detected.

Examples include:

  • Blocking malicious source IP addresses
  • Disabling compromised accounts
  • Updating firewall rules
  • Executing custom response scripts
  • Isolating affected hosts (depending on the environment)

Automated responses should be carefully tested before deployment to avoid disrupting legitimate database users or applications.

Related Guide: How to Configure Wazuh Active Response


MySQL Logs That Wazuh Can Monitor

One of Wazuh’s strengths is its ability to analyze multiple types of MySQL logs simultaneously.

Each log provides unique visibility into database activity, allowing security teams to detect attacks, investigate incidents, troubleshoot operational issues, and meet compliance requirements.

The exact logs available depend on your MySQL configuration and whether optional auditing plugins are enabled.

Error Log

The MySQL error log records operational problems, startup messages, shutdown events, crashes, replication issues, and other critical system events.

Monitoring this log helps detect infrastructure problems before they affect database availability.

Startup and shutdown events

Unexpected database restarts may indicate:

  • System failures
  • Unauthorized maintenance
  • Service crashes
  • Server reboots
  • Malware attempting to disrupt operations

Tracking startup and shutdown events also helps correlate database availability with other security events occurring on the server.

Crashes

Database crashes can result from:

  • Software bugs
  • Disk failures
  • Corrupted tables
  • Memory exhaustion
  • Resource starvation
  • Malicious activity

Repeated crashes should always be investigated, particularly if they occur alongside authentication failures or suspicious system activity.

Permission issues

Permission-related errors often reveal:

  • Incorrect filesystem permissions
  • Failed database access
  • Misconfigured service accounts
  • Unauthorized file modifications

Unexpected permission failures may also indicate attempted privilege escalation.

Replication failures

Organizations using MySQL replication should monitor for:

  • Replication lag
  • Replica synchronization failures
  • Missing binary logs
  • Authentication failures between servers
  • Replication thread errors

These issues may impact database availability or data consistency across environments.

General Query Log

The General Query Log records nearly every client connection and SQL statement executed by the server.

While it provides excellent visibility, enabling it in production can significantly increase disk usage and I/O overhead, so it is often used selectively for troubleshooting or auditing.

User logins

Connection events allow administrators to monitor:

  • Successful logins
  • Failed logins
  • Remote client connections
  • Authentication patterns
  • New database users

Repeated authentication failures may indicate password spraying or brute-force attacks.

SQL queries

Monitoring SQL statements can reveal:

  • Schema modifications
  • Table deletions
  • Unexpected data exports
  • Bulk updates
  • Suspicious administrative commands

Because the General Query Log can become very large on busy servers, organizations should carefully evaluate storage and performance implications before enabling it continuously.

Session activity

Session information provides visibility into:

  • Connection duration
  • Concurrent sessions
  • Idle connections
  • Unexpected client activity
  • Application behavior

This information is useful during incident investigations and performance troubleshooting.

Slow Query Log

The Slow Query Log captures SQL statements that exceed a defined execution time threshold, making it valuable for identifying performance problems and potential abuse.

Long-running queries

Slow queries may result from:

  • Missing indexes
  • Inefficient SQL statements
  • Full table scans
  • Lock contention
  • Poor application design

Monitoring these events helps database administrators optimize performance while identifying unusual query behavior.

Performance bottlenecks

The Slow Query Log can highlight:

  • Resource-intensive workloads
  • CPU-intensive queries
  • Disk I/O bottlenecks
  • Memory pressure
  • Query optimization opportunities

Combining these insights with system metrics provides a more complete view of database performance.

Potential denial-of-service indicators

A sudden increase in slow queries may indicate:

  • Resource exhaustion attacks
  • Malicious query execution
  • Automated scanning tools
  • Misbehaving applications
  • Distributed denial-of-service (DDoS) activity affecting the database

Although slow queries are not always malicious, they can serve as valuable indicators when correlated with other security events.

Binary Logs

Binary logs record changes made to database data and are primarily used for replication and point-in-time recovery.

From a security perspective, they provide visibility into how data changes over time.

Data modifications

Binary logs capture operations such as:

  • INSERT
  • UPDATE
  • DELETE
  • Table modifications
  • Schema changes

Reviewing these events can help investigators determine when sensitive data was altered.

Replication events

Binary logs also contain replication-related activity, allowing administrators to detect:

  • Replication delays
  • Synchronization issues
  • Unexpected replication failures
  • Replica inconsistencies

Monitoring replication events improves both operational reliability and incident response.

Audit Logs (MySQL Enterprise or MariaDB Audit Plugin)

Audit logs provide the most comprehensive record of database activity and are particularly valuable for security monitoring and regulatory compliance.

Oracle’s MySQL Enterprise Audit plugin and the MariaDB Audit Plugin can generate detailed records of user activity and administrative operations.

Authentication

Audit logs record:

  • Login attempts
  • Authentication failures
  • Successful logins
  • Account lockouts
  • Connection sources

These events help identify unauthorized access attempts and compromised accounts.

Privilege changes

Monitoring privilege modifications allows organizations to detect:

  • New administrator accounts
  • GRANT statements
  • REVOKE operations
  • Role assignments
  • Permission changes

Privilege changes should generally be treated as high-priority security events.

Administrative commands

Administrative operations commonly include:

  • User creation
  • Password resets
  • Configuration changes
  • Backup operations
  • Server maintenance commands

Unexpected administrative activity may warrant immediate investigation.

Object access

Audit plugins can record access to database objects such as:

  • Tables
  • Views
  • Stored procedures
  • Functions
  • Schemas

Tracking object access is particularly useful for identifying unauthorized access to sensitive business data and supporting forensic investigations.


Prerequisites

Before integrating Wazuh with MySQL, verify that your environment meets the necessary software, permissions, and connectivity requirements.

Completing these prerequisites beforehand helps ensure a smooth deployment and reduces troubleshooting later.

Supported Wazuh version

Use a supported and up-to-date version of Wazuh to take advantage of the latest security improvements, bug fixes, and rule updates.

Keeping the Wazuh Manager and agents on compatible versions also helps prevent communication and parsing issues.

Related Guide: How to Upgrade a Wazuh Agent

MySQL Server

You should have a functioning MySQL Server installation with the appropriate logs enabled.

Depending on your monitoring objectives, you may need to enable:

  • Error logging
  • General Query Log
  • Slow Query Log
  • Binary logging
  • Audit logging (if available)

Avoid enabling verbose logging unnecessarily on production systems, as it may increase storage consumption and affect performance.

Wazuh Agent installed

The Wazuh Agent must be installed on the server hosting MySQL.

The agent is responsible for:

  • Monitoring MySQL log files
  • Collecting operating system events
  • Monitoring configuration files
  • Forwarding events to the Wazuh Manager

Related Guide: The Ultimate Wazuh Agent Deployment Guide

Root or sudo access

Administrative privileges are typically required to:

  • Install the Wazuh Agent
  • Configure MySQL logging
  • Modify Wazuh configuration files
  • Restart services
  • Verify log collection

On Linux systems, root or sudo access is generally sufficient.

Log file permissions

The Wazuh Agent must have permission to read the configured MySQL log files.

Verify that:

  • Log files exist
  • File paths are correct
  • Appropriate read permissions are assigned
  • Log rotation preserves access permissions

Improper permissions are a common cause of missing log events.

Network connectivity

The MySQL server must be able to communicate with the Wazuh Manager over the required ports.

Before beginning the integration, confirm:

  • Firewall rules permit agent-to-manager communication
  • DNS resolution is working correctly (if using hostnames)
  • No network devices are blocking traffic
  • The agent can successfully register with the manager

Related Guide: Wazuh Agent Not Connecting to Manager? 12 Proven Fixes

Time synchronization

Accurate timestamps are essential for event correlation and incident investigations.

Synchronize both the MySQL server and the Wazuh Manager using a reliable time source, such as NTP or Chrony.

Consistent system clocks ensure that authentication events, SQL activity, and alerts appear in the correct chronological order, making investigations significantly easier.


Step 1: Enable MySQL Logging

Before Wazuh can monitor MySQL activity, the database must generate the appropriate log files.

The more relevant logs you enable, the greater the visibility Wazuh has into authentication attempts, administrative actions, performance issues, and potential security incidents.

Keep in mind that some logs, particularly the General Query Log, can grow rapidly and may impact disk usage and performance on busy production systems.

Enable only the logs that align with your monitoring and compliance requirements.

Enable the Error Log

The MySQL Error Log is the most important log to monitor because it records server startup and shutdown events, crashes, replication issues, plugin errors, and other critical operational problems.

On most Linux systems, the error log is configured in the MySQL configuration file (my.cnf or mysqld.cnf).

Example:

[mysqld]
log_error = /var/log/mysql/error.log

After modifying the configuration, restart the MySQL service for the changes to take effect.

The Error Log is particularly useful for detecting:

  • Unexpected service restarts
  • Replication failures
  • Storage engine errors
  • Permission problems
  • Plugin failures
  • Database corruption

Enable the General Query Log

The General Query Log records client connections and nearly every SQL statement executed by the server.

Enable it by adding or updating the following settings:

[mysqld]
general_log = ON
general_log_file = /var/log/mysql/general.log

Because every SQL statement is recorded, this log can become very large.

Many administrators enable it only temporarily during troubleshooting or security investigations.

Typical use cases include:

  • Investigating unauthorized database access
  • Auditing user activity
  • Monitoring application behavior
  • Detecting suspicious SQL statements

For guidance on configuring query logging, refer to the MySQL Reference Manual.

Enable the Slow Query Log

The Slow Query Log captures SQL statements that exceed a configurable execution time threshold.

Example configuration:

[mysqld]
slow_query_log = ON
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2

This configuration records queries that take longer than two seconds to execute.

Monitoring slow queries helps identify:

  • Inefficient SQL statements
  • Missing indexes
  • Resource-intensive workloads
  • Potential denial-of-service attempts
  • Application performance issues

These events can also provide useful indicators during incident investigations when combined with authentication and system logs.

Enable Audit Logging (Optional)

Organizations with strict compliance requirements may choose to enable database auditing using:

  • MySQL Enterprise Audit
  • MariaDB Audit Plugin
  • Percona Audit Log Plugin (depending on the distribution)

Audit logs provide much richer security information than standard database logs, including:

  • Authentication events
  • Privilege changes
  • Administrative commands
  • Object access
  • User management
  • Database modifications

Although audit logging increases visibility, it also generates significantly more log data.

Consider log retention policies and storage capacity before enabling it in production.


Step 2: Verify MySQL Log Locations

After enabling logging, confirm that MySQL is writing log files to the expected locations.

Wazuh can only monitor logs that actually exist and are accessible by the Wazuh Agent.

The exact paths vary depending on the operating system, Linux distribution, and MySQL installation method.

Linux

Common MySQL log locations include:

Log TypeCommon Location
Error Log/var/log/mysql/error.log
General Query Log/var/log/mysql/general.log
Slow Query Log/var/log/mysql/slow.log
MySQL Configuration/etc/mysql/my.cnf
MySQL Configuration (RHEL)/etc/my.cnf

To verify that logs are being written:

ls -lah /var/log/mysql

You can also monitor log activity in real time:

tail -f /var/log/mysql/error.log

If the files are empty after generating database activity, verify that logging is enabled and that MySQL has permission to write to the specified directory.

Windows

On Windows Server, log locations often depend on the MySQL installation directory.

Typical locations include:

C:\ProgramData\MySQL\MySQL Server 8.0\Data\

or

C:\Program Files\MySQL\MySQL Server 8.0\Data\

Verify that:

  • The log files exist.
  • New entries are being written.
  • The Wazuh Agent service account has permission to read them.

You can also confirm the configured log locations from MySQL itself:

SHOW VARIABLES LIKE '%log%';

This command displays the paths configured for various MySQL log files.


Step 3: Configure the Wazuh Agent

Once MySQL logs are being generated, configure the Wazuh Agent to monitor them.

This is done by editing the agent’s ossec.conf configuration file and defining each log source that should be collected.

Edit ossec.conf

Locate the Wazuh Agent configuration file.

Typical locations include:

Linux

/var/ossec/etc/ossec.conf

Windows

C:\Program Files (x86)\ossec-agent\ossec.conf

Open the file using your preferred text editor.

Related Guide: How to Configure ossec.conf for Log Monitoring in Wazuh

Add MySQL Log Sources

Add a <localfile> entry for each MySQL log you want to monitor.

Example:

<localfile>
  <location>/var/log/mysql/error.log</location>
  <log_format>syslog</log_format>
</localfile>

If your MySQL logs use a different format, choose the appropriate log_format value for your environment.

Each monitored file should have its own <localfile> block.

Configure Multiple Log Files

Most deployments monitor several MySQL logs simultaneously.

Example:

<localfile>
  <location>/var/log/mysql/error.log</location>
  <log_format>syslog</log_format>
</localfile>

<localfile>
  <location>/var/log/mysql/general.log</location>
  <log_format>syslog</log_format>
</localfile>

<localfile>
  <location>/var/log/mysql/slow.log</location>
  <log_format>syslog</log_format>
</localfile>

Depending on your deployment, you may also monitor:

  • Audit logs
  • MySQL service logs
  • Authentication logs
  • Replication logs

Collecting multiple log sources provides richer event correlation and more comprehensive threat detection.

Validate XML Configuration

Before restarting the Wazuh Agent, verify that the XML configuration is valid.

Common configuration errors include:

  • Missing closing tags
  • Invalid nesting
  • Typographical mistakes
  • Incorrect file paths
  • Unsupported XML elements

Even a single XML syntax error can prevent the agent from starting correctly.

Related Guide: How to Fix ossec.conf Syntax Errors in Wazuh Agents


Step 4: Restart the Wazuh Agent

After updating ossec.conf, restart the Wazuh Agent so it begins monitoring the newly configured MySQL log files.

On most Linux distributions:

sudo systemctl restart wazuh-agent

Verify that the service started successfully:

sudo systemctl status wazuh-agent

On Windows, restart the Wazuh Agent service from the Services management console or use PowerShell:

Restart-Service Wazuh

If the agent fails to start, review the agent logs for configuration errors before continuing.


Step 5: Verify Log Collection

Once the Wazuh Agent has restarted, confirm that MySQL events are reaching the Wazuh Manager and appearing in the Dashboard.

Verifying each stage of the data pipeline helps identify configuration issues early.

Check Agent Logs

The first step is to ensure the agent is successfully reading the MySQL log files.

On Linux, review the agent log:

tail -f /var/ossec/logs/ossec.log

Look for messages indicating that the configured log files have been opened and are being monitored.

If errors appear, verify:

  • File paths
  • File permissions
  • XML syntax
  • Log file existence

Check Manager Logs

Next, verify that the Wazuh Manager is receiving events from the agent.

Review the manager log:

tail -f /var/ossec/logs/ossec.log

You should see events arriving from the monitored MySQL server.

If no events appear, investigate:

  • Agent connectivity
  • Firewall rules
  • Agent registration
  • Manager availability

Related Guide: Wazuh Agent Not Connecting to Manager? 12 Proven Fixes

Confirm Events in the Dashboard

Finally, open the Wazuh Dashboard and search for events generated from the MySQL server.

Verify that you can see:

  • Authentication events
  • Error log entries
  • Slow query events
  • Administrative activity
  • Custom rule matches (if configured)

If events appear in the Dashboard, the integration is functioning correctly.

You can then begin refining detection rules and building custom dashboards for your database environment.


Step 6: Create Custom Detection Rules

While Wazuh includes many built-in detection rules, custom rules allow you to identify database activity that is unique to your organization.

For example, you may want to alert only when a privileged account performs certain actions or when a sensitive database is modified.

Related Guide: How to Create Custom Detection Rules in Wazuh (With Examples)

Detect Multiple Failed Logins

Repeated authentication failures often indicate:

  • Brute-force attacks
  • Password spraying
  • Credential stuffing
  • Misconfigured applications

A custom rule can count multiple failed login events from the same IP address or user account within a defined time window and generate a higher-severity alert when a threshold is exceeded.

Detect New Administrative Users

Database administrators are rarely created during normal application operations.

Consider generating alerts whenever events such as the following occur:

  • CREATE USER
  • ALTER USER
  • Administrative role assignments
  • New root-equivalent accounts

These events should typically receive medium- or high-severity classifications depending on your environment.

Detect Privilege Grants

Privilege changes are especially important because attackers often elevate permissions after gaining initial access.

Monitor statements such as:

  • GRANT
  • REVOKE
  • Role assignments
  • Global privilege changes

Unexpected privilege modifications should be investigated immediately, particularly outside of approved maintenance windows.

Detect Database Drops

Dropping databases or critical tables is a high-risk administrative action.

Useful detections include:

  • DROP DATABASE
  • DROP TABLE
  • Bulk schema deletions
  • Unexpected object removal

Generating immediate alerts for these operations can significantly reduce response time during destructive attacks or accidental administrative errors.

Detect Suspicious SQL Statements

Not every SQL statement warrants an alert, but some commands deserve closer scrutiny.

Examples include:

  • Large data exports
  • Mass DELETE operations
  • Unexpected UPDATE statements affecting many rows
  • SQL injection indicators
  • Access to sensitive tables
  • Schema modifications performed by non-administrative users

Correlating these events with authentication logs and endpoint activity can help distinguish legitimate maintenance from malicious behavior.

OWASP recommends monitoring unusual database activity as part of a layered defense strategy against injection attacks and unauthorized data access.

Detect Unexpected Configuration Changes

Configuration changes can weaken database security or indicate post-compromise activity.

Consider monitoring:

  • my.cnf
  • mysqld.cnf
  • SSL certificate files
  • Authentication plugins
  • Audit plugin configuration
  • Replication settings

Wazuh’s File Integrity Monitoring (FIM) can generate alerts whenever these files are created, modified, deleted, or have their permissions changed unexpectedly.

Related Guide: How to Configure File Integrity Monitoring (FIM) in Wazuh


Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *