By default the WP Security Audit Log stores the WordPress activity log in separate tables in the WordPress database. However you can configure the plugin to store the activity log in an external database. By storing the activity log in an external database you can:
- Control and better manage the size of your WordPress database
- Segregate the logs from the database, which is a more secure setup and typically recommended by regulatory compliance rules.
This document explains how to store the activity log of your WordPress site to an external database, using the WP Security Audit Log plugin. This process consists of three steps:
- Setting up an external database connection in the plugin
- Configuring the plugin to use the new external database to store the activity log
- Migrating the activity log from the WordPress database to the new external database.
1. Setting Up an External Database Connection for the Activity Log
To setup an external database connection in the plugin:
- Click on DB/Archive/Mirror node in the plugin menu.
- Click the Create a Connection button to launch the connection setup wizard.
- Select MySQL Database from the Type of Connection drop down menu in the first step of the wizard.
- In the second step of the wizard specify all of the following in the respective placeholder:
- Database Name
- Database User
- Database Password
- Database Hostname
- Database Base Prefix (Enable the setting Use Website URL as table prefix to use the website URL as prefix).
Note: If your MySQL server is configured to accept SSL encrypted communication, enable the SSL setting and specify the paths to the CA SSL certificate and Server SSL Certificate. If your server requires a client certificate you can also configure that.
- In the last step of the wizard, specify a name for the connection. Connection names are just reference for you and can be up to 25 characters long and can only consist of letters, numbers and underscores.
2. Configuring the Plugin to Store Activity Log to an External Database
Once the external database connection is setup configure the plugin to start using it for storing the activity log in the external database, as explained below:
- Click on DB/Archive/Mirror in the plugin menu.
- Click on the External Storage tab.
- Select the newly created connection form the Connection drop down menu.
- Enable the buffer by enabling the option Use Buffer.
Note: It is recommended to use to Buffer so the state of connection of the external database does not effect the performance of the website in case it is slow or unavailable.
- Click the Save & Test Changes to save the new external database configuration and test it.
At this stage the plugin is using the newly configured external database. So any new activity log events will be saved in the new database.
3. Migrating the Activity Log from the WordPress Database
Even though the plugin is now using an external database for the activity log, the old activity log events are still stored in the WordPress database. To migrate the events to the new external database simply click the Migrate Events to External Storage button.
Migrating Back to the WordPress Database
If for some reason you want to stop using the external database migrate the activity log from the external database to the WordPress database by clicking the Migrate Events to WordPress Database.
Refer to the getting started guide for external databases & third party services for more information on other integrations and activity log management.