How To Audit Percona Server for MySQL?
Introduction
In today’s data-driven world, ensuring the security and integrity of your database environment is more critical than ever. Auditing database activities plays a fundamental role in maintaining compliance, detecting unauthorized access, and safeguarding sensitive information. For organizations using Percona Server for MySQL, a robust open-source MySQL-compatible database solution, implementing a reliable audit trail becomes essential. While Percona Server for MySQL offers native audit capabilities, additional tools like DataSunrise can significantly enhance these features in complex environments. This article will guide you through auditing Percona Server for MySQL effectively using both native and third-party solutions.
How to Perform Native Database Audit: Audit Log Filter Plugin
Percona Server for MySQL provides built-in audit capabilities through its Audit Log Plugin. This feature allows seamless tracking and logging of database activities, offering a powerful tool for organizations aiming to monitor user interactions, query executions, and potential security threats.
Plugin Installation
To enable the audit log plugin, use the following bash command:
cd /usr/share/mysql
mysql -u -D database -p < audit_log_filter_linux_install.sql
Verification
After installing the plugin, verify its activation by running:
SELECT * FROM information_schema.PLUGINS WHERE PLUGIN_NAME LIKE '%audit%';
Plugin Configuration
To log all activities, configure the audit log settings by setting the audit policy to ALL
:
SET GLOBAL audit_log_policy = 'ALL';
Specify the log format and output file as needed. JSON is a popular format for its readability:
SET GLOBAL audit_log_format = 'JSON';
SET GLOBAL audit_log_file = '/var/log/mysql/audit.log';
Use the following command to view the logs:
tail -f /var/log/mysql/audit.log
Benefits of Using a Native Percona Audit Log Filter Plugin
Several key features make the native audit log plugin valuable:
- Granular Logging: Tracks specific user activities, queries, and connections.
- Customizable Filters: Allows filtering by user accounts, SQL command types, and databases.
- Real-Time Monitoring: Offers real-time insights into database activities.
- Tamper-Evident Logs: Protects the integrity of audit logs by making them resistant to tampering.
More detailed configuration options can be found in the Percona Server for MySQL documentation.
Example Audit Log Output Table
Here’s an example of how the audit log output might appear when formatted as a markdown table. This layout highlights the audit log structure and helps users better understand the information captured:
Timestamp | User | Host | Command Class | SQL Text |
---|---|---|---|---|
2023-10-01 12:34:56 | admin_user | 192.168.1.100 | SELECT | SELECT * FROM customers WHERE id = 123; |
2023-10-01 12:35:10 | app_user | 192.168.1.101 | INSERT | INSERT INTO orders (product_id, quantity) VALUES (456, 2); |
2023-10-01 12:35:45 | admin_user | 192.168.1.100 | UPDATE | UPDATE customers SET name = ‘John Doe’ WHERE id = 123; |
2023-10-01 12:36:20 | app_user | 192.168.1.101 | DELETE | DELETE FROM orders WHERE id = 789; |
Database Audit with DataSunrise
While Percona Server for MySQL’s native audit capabilities are robust, organizations with complex security needs may gain additional benefits from integrating third-party solutions like DataSunrise. This all-in-one security solution enhances the native features of Percona Server for MySQL, offering advanced monitoring, security, and compliance tools.
DataSunrise Proxy Setup

One major advantage of DataSunrise is its ability to function as a database proxy, positioned between your application and the database. This arrangement enables real-time monitoring and blocking of suspicious activities. Security rules can also be created to block connections from specific IP addresses or restrict access to sensitive data. For more information on security rules, check out Security Rules against SQL Injections.
Creating Security Rules in DataSunrise

Advanced audit trail features allow DataSunrise to generate detailed reports on database activities. Reports can be customized for specific compliance requirements, including GDPR or HIPAA. Real-time notifications further help your team respond swiftly to potential security threats. Learn more about Audit Logs and Database Activity Monitoring.
Transactional Trails in DataSunrise

By integrating DataSunrise with Percona Server for MySQL, organizations can boost security and compliance, ensuring a robust and resilient database environment. For more insights into database security, explore Database Security and Data Security.
Conclusion
Auditing Percona Server for MySQL remains a crucial step toward maintaining a secure and compliant database environment. Although the native audit log plugin provides a solid foundation, incorporating third-party solutions like DataSunrise can dramatically enhance auditing capabilities. With advanced features such as real-time monitoring, customizable security rules, and detailed audit trails, DataSunrise serves as an invaluable tool for organizations with complex security requirements.
For a more comprehensive experience, consider booking a personalized online demo or downloading the trial version from the DataSunrise website. Combining the native capabilities of Percona Server for MySQL with DataSunrise’s advanced features ensures that your database environment remains secure, compliant, and optimized for performance. For additional resources, visit DataSunrise Knowledge Center or explore Audit Guide for more detailed information.