|
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 |
| 16 | +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` |
| 17 | +3. When the plugin is not loaded and no `-D` option is provided, you must specify the `mysql` database when running the script |
18 | 18 |
|
| 19 | +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. |
19 | 20 |
|
20 |
| -```{.bash data-prompt="$"} |
21 |
| -$ mysql -u -D database -p < audit_log_filter_linux_install.sql |
| 21 | +### Install the component |
| 22 | + |
| 23 | +To install the plugin using the script, you must specify the `mysql` database. You can do this in two ways: |
| 24 | + |
| 25 | +Option 1: Run the script from the command line with the `-D mysql` option: |
| 26 | + |
| 27 | +```bash |
| 28 | +mysql -u root -p -D mysql < /path/to/mysql/share/audit_log_filter_linux_install.sql |
| 29 | +``` |
| 30 | + |
| 31 | +Option 2: Connect to `mysql` database and run the script interactively: |
| 32 | + |
| 33 | +```sql |
| 34 | +mysql> use mysql; |
| 35 | +mysql> source /path/to/mysql/share/audit_log_filter_linux_install.sql; |
| 36 | +``` |
| 37 | + |
| 38 | +Replace `/path/to/mysql/share/` with the actual path to your MySQL installation's share directory. |
| 39 | + |
| 40 | +### Verify installation |
| 41 | + |
| 42 | +After you run the script, verify that the required tables are created: |
| 43 | + |
| 44 | +```sql |
| 45 | +mysql> show tables in mysql like 'aud%'; |
| 46 | +``` |
| 47 | + |
| 48 | +Expected output: |
| 49 | + |
| 50 | +``` |
| 51 | ++------------------------+ |
| 52 | +| Tables_in_mysql (aud%) | |
| 53 | ++------------------------+ |
| 54 | +| audit_log_filter | |
| 55 | +| audit_log_user | |
| 56 | ++------------------------+ |
| 57 | +2 rows in set (0.00 sec) |
| 58 | +``` |
| 59 | + |
| 60 | +## Alternative: INSTALL PLUGIN method |
| 61 | + |
| 62 | +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. |
| 63 | + |
| 64 | +### Verify plugin installation |
| 65 | + |
| 66 | +Check that the plugin is properly installed: |
| 67 | + |
| 68 | +```sql |
| 69 | +mysql> SHOW PLUGINS LIKE 'audit_log_filter'; |
22 | 70 | ```
|
23 | 71 |
|
24 |
| -To verify the plugin installation, run the following command: |
| 72 | +Expected output: |
25 | 73 |
|
26 |
| -```{.bash data-prompt="mysql>"} |
27 |
| -mysql> SELECT PLUGIN_NAME, PLUGIN_STATUS FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME LIKE 'audit%'; |
28 | 74 | ```
|
| 75 | ++-------------------+----------+--------------------+ |
| 76 | +| Name | Status | Type | |
| 77 | ++-------------------+----------+--------------------+ |
| 78 | +| audit_log_filter | ACTIVE | AUDIT | |
| 79 | ++-------------------+----------+--------------------+ |
| 80 | +1 row in set (0.00 sec) |
| 81 | +``` |
| 82 | + |
| 83 | +### Test filter functionality |
| 84 | + |
| 85 | +Test that the audit log filter is working correctly: |
| 86 | + |
| 87 | +```sql |
| 88 | +mysql> SELECT audit_log_filter_set_filter('log_all', '{"filter": {"log": true}}'); |
| 89 | +``` |
| 90 | + |
| 91 | +Expected output: |
| 92 | + |
| 93 | +``` |
| 94 | ++---------------------------------------------------------------------+ |
| 95 | +| audit_log_filter_set_filter('log_all', '{"filter": {"log": true}}') | |
| 96 | ++---------------------------------------------------------------------+ |
| 97 | +| ERROR: Failed to check filtering rule name existence | |
| 98 | ++---------------------------------------------------------------------+ |
| 99 | +1 row in set (0.00 sec) |
| 100 | +``` |
| 101 | + |
| 102 | +!!! note |
| 103 | + |
| 104 | + This error occurs when the plugin is installed without the required tables. Using the SQL script prevents this issue. |
| 105 | + |
| 106 | +### Fix missing tables |
| 107 | + |
| 108 | +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: |
| 109 | + |
| 110 | +```bash |
| 111 | +mysql -u root -p -D mysql < /path/to/mysql/share/audit_log_filter_linux_install.sql |
| 112 | +``` |
| 113 | + |
| 114 | +Or interactively: |
| 115 | + |
| 116 | +```sql |
| 117 | +mysql> use mysql; |
| 118 | +mysql> source /path/to/mysql/share/audit_log_filter_linux_install.sql; |
| 119 | +``` |
| 120 | + |
| 121 | +This operation creates the missing tables without reinstalling the plugin. |
| 122 | + |
| 123 | +## Additional information |
| 124 | + |
| 125 | +For information about upgrading the audit log filter plugin, see the upgrade documentation. |
29 | 126 |
|
30 |
| -??? example "Expected output" |
| 127 | +## References |
31 | 128 |
|
32 |
| - ```text |
33 |
| - +--------------------+---------------+ |
34 |
| - | PLUGIN_NAME | PLUGIN_STATUS | |
35 |
| - +--------------------+---------------+ |
36 |
| - | audit_log_filter | ACTIVE | |
37 |
| - +--------------------+---------------+ |
38 |
| - ``` |
| 129 | +[Audit Log Filter Overview](audit-log-filter-overview.md) |
39 | 130 |
|
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. |
| 131 | +[Audit Log Filter Variables & Functions](audit-log-filter-variables.md) |
0 commit comments