|
1 | 1 | # Install the Audit Log Filter |
2 | 2 |
|
3 | | -The `plugin_dir` system variable defines the plugin library location. If needed, at server startup, set the `plugin_dir` variable. |
| 3 | +## Installation script |
4 | 4 |
|
5 | | -When upgrading a MySQL installation, plugins are not automatically upgraded. You may need to manually load the plugin after the MySQL upgrade. |
| 5 | +The recommended way to install the plugin is to use the `audit_log_filter_linux_install.sql` script, located in the share directory, which creates the required tables before installing the plugin. |
6 | 6 |
|
7 | | -In the `share` directory, locate the `audit_log_filter_linux_install.sql `script. |
| 7 | +### Prerequisites |
8 | 8 |
|
9 | | -Implemented in 8.0.34, at the time you run the script, you can select the database used to store the JSON filter tables. |
| 9 | +The `plugin_dir` system variable defines the plugin library location. When you need a custom location, set the `plugin_dir` variable at server startup. |
10 | 10 |
|
11 | | -* If the plugin is loaded, the installation script takes the database name from the `audit_log_filter_database` variable |
12 | | -* If the plugin is not loaded, but passes the `-D db_name` to the mysql client when the installation script runs, uses the `db_name`. |
13 | | -* If the plugin is not loaded and the `-D` option is not provided, the installation script creates the required tables in the default database name `mysql`. |
| 11 | +### Database selection |
14 | 12 |
|
15 | | -You can also designate a different database with the `audit_log_filter_database` system variable. The database name cannot be NULL or exceed 64 characters. If the database name is invalid, the audit log filter tables are not found. |
| 13 | +The script determines the target database using the following priority: |
16 | 14 |
|
17 | | -With 8.0.34 and higher, use this command: |
| 15 | +1. When the plugin is already loaded, the script uses the database name from the `audit_log_filter_database` variable |
18 | 16 |
|
| 17 | +2. When the plugin is not loaded, but you pass the `-D db_name` option to the mysql client when running the script, the script uses the specified `db_name` |
19 | 18 |
|
20 | | -```{.bash data-prompt="$"} |
21 | | -$ mysql -u -D database -p < audit_log_filter_linux_install.sql |
| 19 | +3. When the plugin is not loaded and no `-D` option is provided, you must specify the `mysql` database when running the script |
| 20 | + |
| 21 | +You can also designate a different database with the `audit_log_filter_database` system variable. The database name cannot be NULL or exceed 64 characters. When the database name is invalid, the audit log filter tables are not found. |
| 22 | + |
| 23 | +### Install the component |
| 24 | + |
| 25 | +To install the plugin using the script, you must specify the `mysql` database. You can do this in two ways: |
| 26 | + |
| 27 | +Option 1: Run the script from the command line with the `-D mysql` option: |
| 28 | + |
| 29 | +```bash |
| 30 | +mysql -u root -p -D mysql < /path/to/mysql/share/audit_log_filter_linux_install.sql |
| 31 | +``` |
| 32 | + |
| 33 | +Option 2: Connect to `mysql` database and run the script interactively: |
| 34 | + |
| 35 | +```sql |
| 36 | +mysql> use mysql; |
| 37 | +mysql> source /path/to/mysql/share/audit_log_filter_linux_install.sql; |
| 38 | +``` |
| 39 | + |
| 40 | +Replace `/path/to/mysql/share/` with the actual path to your MySQL installation's share directory. |
| 41 | + |
| 42 | +### Verify installation |
| 43 | + |
| 44 | +After you run the script, verify that the required tables are created: |
| 45 | + |
| 46 | +```sql |
| 47 | +mysql> show tables in mysql like 'aud%'; |
| 48 | +``` |
| 49 | + |
| 50 | +Expected output: |
| 51 | + |
| 52 | +``` |
| 53 | ++------------------------+ |
| 54 | +| Tables_in_mysql (aud%) | |
| 55 | ++------------------------+ |
| 56 | +| audit_log_filter | |
| 57 | +| audit_log_user | |
| 58 | ++------------------------+ |
| 59 | +2 rows in set (0.00 sec) |
| 60 | +``` |
| 61 | + |
| 62 | +## Alternative: INSTALL PLUGIN method |
| 63 | + |
| 64 | +You can also install the plugin using the `INSTALL PLUGIN` command, but this method does not create the required tables and will cause filter operations to fail. |
| 65 | + |
| 66 | +### Verify plugin installation |
| 67 | + |
| 68 | +Check that the plugin is properly installed: |
| 69 | + |
| 70 | +```sql |
| 71 | +mysql> SHOW PLUGINS LIKE 'audit_log_filter'; |
| 72 | +``` |
| 73 | + |
| 74 | +Expected output: |
| 75 | + |
| 76 | +``` |
| 77 | ++-------------------+----------+--------------------+ |
| 78 | +| Name | Status | Type | |
| 79 | ++-------------------+----------+--------------------+ |
| 80 | +| audit_log_filter | ACTIVE | AUDIT | |
| 81 | ++-------------------+----------+--------------------+ |
| 82 | +1 row in set (0.00 sec) |
| 83 | +``` |
| 84 | + |
| 85 | +### Test filter functionality |
| 86 | + |
| 87 | +Test that the audit log filter is working correctly: |
| 88 | + |
| 89 | +```sql |
| 90 | +mysql> SELECT audit_log_filter_set_filter('log_all', '{"filter": {"log": true}}'); |
| 91 | +``` |
| 92 | + |
| 93 | +Expected output: |
| 94 | + |
| 95 | +``` |
| 96 | ++---------------------------------------------------------------------+ |
| 97 | +| audit_log_filter_set_filter('log_all', '{"filter": {"log": true}}') | |
| 98 | ++---------------------------------------------------------------------+ |
| 99 | +| ERROR: Failed to check filtering rule name existence | |
| 100 | ++---------------------------------------------------------------------+ |
| 101 | +1 row in set (0.00 sec) |
22 | 102 | ``` |
23 | 103 |
|
24 | | -To verify the plugin installation, run the following command: |
| 104 | +!!! note |
| 105 | + |
| 106 | + This error occurs when the plugin is installed without the required tables. Using the SQL script prevents this issue. |
25 | 107 |
|
26 | | -```{.bash data-prompt="mysql>"} |
27 | | -mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'audit%'; |
| 108 | +### Fix missing tables |
| 109 | + |
| 110 | +When you have already installed the audit log plugin but are missing the required tables, you can run the `audit_log_filter_linux_install.sql` script to create the audit tables in the `mysql` database: |
| 111 | + |
| 112 | +```bash |
| 113 | +mysql -u root -p -D mysql < /path/to/mysql/share/audit_log_filter_linux_install.sql |
28 | 114 | ``` |
29 | 115 |
|
30 | | -??? example "Expected output" |
| 116 | +Or interactively: |
| 117 | + |
| 118 | +```sql |
| 119 | +mysql> use mysql; |
| 120 | +mysql> source /path/to/mysql/share/audit_log_filter_linux_install.sql; |
| 121 | +``` |
| 122 | + |
| 123 | +This operation creates the missing tables without reinstalling the plugin. |
| 124 | + |
| 125 | +## Additional information |
| 126 | + |
| 127 | +For information about upgrading the audit log filter plugin, see the upgrade documentation. |
| 128 | + |
| 129 | +## References |
31 | 130 |
|
32 | | - ```text |
33 | | - +--------------------+---------------+ |
34 | | - | PLUGIN_NAME | PLUGIN_STATUS | |
35 | | - +--------------------+---------------+ |
36 | | - | audit_log_filter | ACTIVE | |
37 | | - +--------------------+---------------+ |
38 | | - ``` |
| 131 | +[Audit Log Filter Overview](audit-log-filter-overview.md) |
39 | 132 |
|
40 | | -After the installation, you can use the `--audit_log_filter` option when restarting the server. To prevent the server from not running the plugin use `--audit_log_filter` with either the `FORCE` or the `FORCE_PLUS_PERMANENT` values. |
| 133 | +[Audit Log Filter Variables & Functions](audit-log-filter-variables.md) |
0 commit comments