Common SQL Errors

MySQL Error 3222: ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS - How to Fix Missing Audit JSON Filter

Galaxy Team
August 8, 2025

MySQL cannot locate the named JSON filter when creating, altering, or dropping an audit log filter policy.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 3222 ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS?

ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS appears when MySQL cannot find the JSON filter referenced in an audit log policy. Verify the filter exists in mysql.audit_log_filter or recreate it, then retry the statement.

Error Highlights

Typical Error Message

ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS

Error Type

Configuration Error

Language

MySQL

Symbol

ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS was added in 5.7.22.

Error Code

3222

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 3222 ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS?

MySQL raises error 3222 with condition name ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS when a statement refers to a JSON filter that is not present in the mysql.audit_log_filter table.

The error was introduced in MySQL 5.7.22 with the JSON - based audit log filtering framework. It stops CREATE, ALTER, or DROP audit log filter commands that reference a non existent filter name, preventing silent misconfiguration of the audit trail.

What Causes This Error?

The filter name in your SQL statement may be misspelled or use the wrong letter case, so MySQL fails the lookup.

An earlier DROP FILTER command or schema refresh might have removed the filter before this statement executed.

Filters are connection specific in some workflows; running the policy creation in a different session can expose a missing temporary filter.

How to Fix ER_AUDIT_LOG_JSON_FILTER_DOES_NOT_EXISTS

First query the mysql.audit_log_filter table to confirm the filter record is absent. If missing, recreate it with CREATE AUDIT filter syntax, then rerun your policy statement.

If the filter exists but the name does not match exactly, correct the spelling or quote the identifier.

Common Scenarios and Solutions

During deployment automation, scripts sometimes execute DROP IF EXISTS on filters in the wrong order. Ensure the CREATE filter step precedes every policy reference.

When cloning databases, audit_log_filter rows may not be exported. Run mysqldump with --system or manually copy the rows before applying policies.

Best Practices to Avoid This Error

Version control audit_log_filter definitions alongside schema migrations so filters are always present before policies run.

Use IF NOT EXISTS logic when creating filters, and include automated tests that query mysql.audit_log_filter after migrations.

Related Errors and Solutions

Error 3219 ER_AUDIT_LOG_FILTER_DOES_NOT_EXIST occurs when the classic XML filter engine cannot locate a filter. The fix is similar: create or rename the filter.

Syntax error 1149 might appear if the JSON definition body is malformed, so validate all JSON with JSON_VALID() before executing CREATE AUDIT.

Common Causes

Missing Filter Record

The named filter never existed or was dropped in an earlier migration.

Typographical Errors

Case sensitive or misspelled filter names prevent MySQL from matching existing records.

Improper Deployment Order

Automation scripts create policies before filters, triggering the lookup failure.

Related Errors

ER_AUDIT_LOG_FILTER_DOES_NOT_EXIST (3219)

Raised when the XML audit filter engine cannot find a named filter.

ER_AUDIT_LOG_INVALID_JSON_USER (3221)

Appears if the JSON defining users in a filter policy is not valid.

ER_AUDIT_LOG_JSON_FORMAT_ERROR (3223)

Thrown when the FILTER clause contains malformed JSON.

FAQs

Can I disable auditing instead of fixing the filter?

You can, but it removes critical security logging. Recreating the filter is safer.

Does the filter name check consider case sensitivity?

Yes, the name column in mysql.audit_log_filter is case sensitive on most systems.

Will recreating filters impact running sessions?

New filters take effect immediately for new connections; existing sessions keep prior settings.

How does Galaxy help with this error?

Galaxy lets you version and share CREATE AUDIT scripts, ensuring filters are created before policies during deployments.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo