Common SQL Errors

MySQL Error 1359: ER_TRG_ALREADY_EXISTS - Trigger already exists - How to Fix and Prevent

Galaxy Team
August 6, 2025

<p>MySQL throws error 1359 (ER_TRG_ALREADY_EXISTS) when you try to create a trigger that already exists with the same timing and event on the target table.</p>

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 1359 ER_TRG_ALREADY_EXISTS?

<p>MySQL Error 1359: ER_TRG_ALREADY_EXISTS means a trigger with the same name or the same timing-event pair already exists in the database. Drop or rename the existing trigger before creating a new one to resolve the issue.</p>

Error Highlights

Typical Error Message

Trigger already exists

Error Type

Object Definition Error

Language

MySQL

Symbol

ER_TRG_ALREADY_EXISTS

Error Code

1359

SQL State

HY000

Explanation

Table of Contents

What is MySQL Error 1359: ER_TRG_ALREADY_EXISTS?

MySQL raises Error 1359 with the message "Trigger already exists" when a CREATE TRIGGER statement conflicts with an existing trigger definition.

The conflict can be by name or by the same combination of timing (BEFORE or AFTER) and event (INSERT, UPDATE, DELETE) on a given table.

What Causes This Error?

The error appears if a trigger of the same name is already present in the current database.

MySQL also rejects multiple triggers for the same table with identical timing-event pairs, even when names differ.

How to Fix MySQL Error 1359 ER_TRG_ALREADY_EXISTS

Confirm whether the trigger truly exists with SHOW TRIGGERS and DROP it if no longer needed, then re-create your new trigger.

If both triggers are required, rename your new trigger or adjust timing/event so each pair is unique.

Common Scenarios and Solutions

Schema migrations that re-apply CREATE TRIGGER statements often meet this error. Add IF NOT EXISTS logic around the DROP TRIGGER command.

Developers working in shared environments sometimes duplicate trigger names. Use naming conventions including table and action to avoid overlap.

Best Practices to Avoid This Error

Version-control DDL scripts and run idempotent migration steps that drop or check for existing triggers before creation.

Adopt descriptive trigger names and document timing-event pairs to keep the catalog clear.

Related Errors and Solutions

Error 1235 sql_mode conflicts arise when a trigger statement violates restrictive server modes. Adjust sql_mode or rewrite the trigger.

Error 1146 table does not exist occurs if the trigger references a table that has been dropped. Recreate the referenced table or update the trigger body.

Common Causes

Duplicate trigger name

A trigger with the same identifier is already defined in the current schema.

Duplicate timing-event pair

A second BEFORE INSERT, AFTER UPDATE, or similar trigger on the same table violates MySQL's one-per-pair rule.

Mistaken migration rerun

Automated deployment reruns the same CREATE TRIGGER script without first removing the original trigger.

Lack of environment isolation

Multiple developers create triggers on a shared database without coordination, causing naming collisions.

Related Errors

MySQL Error 1235: ER_TRG_NO_SUCH_ROW_IN_TRG

Occurs when a trigger references nonexistent fields. Update field names or table schema.

MySQL Error 1360: ER_TRG_DOES_NOT_EXIST

Raised when attempting to drop a trigger that is not found. Double-check trigger name or database context.

MySQL Error 1468: ER_NO_SUCH_TRIGGER

Appears during ALTER TRIGGER on a missing trigger. Ensure correct name and schema.

FAQs

Can I have multiple triggers on the same table?

Yes, but each timing-event pair (BEFORE INSERT, AFTER UPDATE, etc.) can have only one trigger. Use different timing or event or merge logic.

Does trigger name uniqueness span the whole server?

Trigger names must be unique only within the current database schema.

How do I safely redeploy triggers in CI/CD?

Include DROP TRIGGER IF EXISTS before CREATE TRIGGER in migration scripts to make them idempotent.

Can Galaxy help prevent trigger duplication?

Galaxy's version-controlled SQL editor highlights existing object names and provides linting so duplicate triggers are caught before execution.

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